ROSE 0.11.145.147
SgNode.h
1
2#ifndef ROSE_SgNode_H
3#define ROSE_SgNode_H
4#include <RoseFirst.h>
5#include <Cxx_GrammarDeclarations.h>
6
7
8
9/* #line 1 "/workspace/src/ROSETTA/Grammar/grammarClassDeclarationMacros.macro" */
10
11// WARNING -- GENERATED CODE -- DO NOT MODIFY THIS CODE -- WARNING!
12// This code is automatically generated for each
13// terminal and non-terminal within the defined
14// grammar. There is a simple way to change the
15// code to fix bugs etc. See the ROSE README file
16// for directions.
17
18// tps: (02/22/2010): Adding DLL export requirements
19#include "rosedll.h"
20
21// predeclarations for SgNode
22
23/* #line 24 "../../../src/frontend/SageIII//SgNode.h" */
24/* #line 2 "/workspace/src/ROSETTA/Grammar/Node.code" */
25
26
27#include <ROSE_DEPRECATED.h>
28#include <semaphore.h>
29#include <rosePublicConfig.h>
30#include "setup.h"
31#include "Map.h"
32#include <boost/format.hpp>
33#include <boost/serialization/access.hpp>
34#include <boost/serialization/base_object.hpp>
35#include <boost/serialization/map.hpp>
36#include <boost/serialization/set.hpp>
37#include <boost/serialization/vector.hpp>
38#include <boost/serialization/version.hpp>
39#include <Sawyer/CommandLine.h>
40#include <Sawyer/Interval.h>
41#include <Sawyer/IntervalSet.h>
42
43#include "processSupport.h"
44#define __builtin_constant_p(exp) (0)
45
46#ifdef ROSE_ENABLE_BINARY_ANALYSIS
47#include <Rose/BinaryAnalysis/AddressSet.h>
48#include <Rose/BinaryAnalysis/RelativeVirtualAddress.h>
49#include <Rose/BinaryAnalysis/AddressInterval.h>
50#include <Rose/BinaryAnalysis/AddressIntervalSet.h>
51#include <rose_extent.h> // deprecated
52#include <Rose/BinaryAnalysis/RegisterDescriptor.h>
53#include <Rose/BinaryAnalysis/InstructionMap.h>
54#include <ROSE_NELMTS.h>
55#endif
56
57#include <Rose/Constants.h>
58#include <sageHash.h>
59#include <sageTraversal.h>
60#include <sageRti.h>
61#include <sageCopy.h>
62#include <sageMemory.h>
63#include <Cxx_GrammarVariants.h>
64#include <Cxx_GrammarStorageClasses.h>
65#include <virtualCFG.h>
66
67namespace Rose { namespace Traits { namespace generated { template <typename NodeT> struct describe_node_t; } } }
68namespace Rose { namespace Traits { namespace generated { template <typename NodeT, typename FieldT, FieldT NodeT::* fld_ptr> struct describe_field_t; } } }
69
70#ifdef ROSE_ENABLE_BINARY_ANALYSIS
71// Version numbers for SgAsm* nodes. Used for backward compatibility. */
72BOOST_CLASS_VERSION(SgAsmInstruction, 1);
73#endif
74
77class AstAttribute;
80
81// DQ (3/18/2006): Forward declarations of classes used to control and tailor the code generation.
82class UnparseDelegate;
83class UnparseFormatHelp;
84
85// DQ (4/32/2006): g++ 4.0.2 requires a forward declaration for this (a friend class declaration is not sufficient!)
86class AstSpecificDataManagingClassStorageClass;
87
88
89
90/* #line 13 "/workspace/src/ROSETTA/Grammar/grammarClassDeclarationMacros.macro after subst for $PREDECLARATIONS" */
91
92/* #line 14 "/workspace/src/ROSETTA/Grammar/grammarClassDeclarationMacros.macro" */
93
94#if 1
95// Class Definition for SgNode
96class ROSE_DLL_API SgNode
97 {
98 public:
99
100
101/* #line 102 "../../../src/frontend/SageIII//SgNode.h" */
102
103 virtual SgNode* copy ( SgCopyHelp& help) const;
104// Start of memberFunctionString
105/* #line 1 "/workspace/src/ROSETTA/Grammar/Common.code" */
106
107// *** COMMON CODE SECTION BEGINS HERE ***
108
109 public:
110
111 // DQ (3/25/3006): I put this back in because it had the logic for where the copy function required
112 // and not required which is required to match the other aspects of the copy mechanism code generation.
113 // Specifically it is a problem to declare the copy function everywhere because it is not implemented
114 // for the SgSymbol IR nodes. I'm not clear why it is not implemented for these IR nodes.
115 /* \brief Copies AST (whole subtree, depending on the SgCopyHelp class */
116 // virtual SgNode* copy ( const SgCopyHelp & help) const;
117
119 virtual std::string class_name() const;
120
122 virtual VariantT variantT() const; // MS: new variant used in tree traversal
123
125 // King84 (2010.08.16): Moved this to an enum to save space, since it's only used at compiler-time anyway.
126 // static const VariantT static_variant = V_SgNode;
127 enum { static_variant = V_SgNode };
128
129 /* the generated cast function */
131 ROSE_DLL_API friend SgNode* isSgNode( SgNode * s );
132
134 ROSE_DLL_API friend const SgNode* isSgNode( const SgNode * s );
135
136 // ******************************************
137 // * Memory Pool / New / Delete
138 // ******************************************
139
140 public:
142 static const unsigned pool_size; //
144 static std::vector<unsigned char *> pools; //
146 static SgNode * next_node; //
147
149 static unsigned long initializeStorageClassArray(SgNodeStorageClass *); //
150
152 static void clearMemoryPool(); //
153 static void deleteMemoryPool(); //
154
156 static void extendMemoryPoolForFileIO(); //
157
159 static SgNode * getPointerFromGlobalIndex(unsigned long); //
161 static SgNode * getPointerFromGlobalIndex(AstSpecificDataManagingClass *, unsigned long); //
162
164 static unsigned long getNumberOfValidNodesAndSetGlobalIndexInFreepointer(unsigned long); //
166 static void resetValidFreepointers(); //
168 static unsigned long getNumberOfLastValidPointer(); //
169
170
171#if defined(INLINE_FUNCTIONS)
173 inline void *operator new (size_t size);
174#else
176 void *operator new (size_t size);
177#endif
179 void operator delete (void* pointer, size_t size);
180
181 // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
182 void operator delete (void* pointer)
183 {
184 // This is the generated delete operator...
185 SgNode::operator delete (pointer,sizeof(SgNode));
186 }
187
189 static size_t numberOfNodes();
190
192 static size_t memoryUsage();
193
194 // End of scope which started in IR nodes specific code
195 /* */
196
197 /* name Internal Functions
198 \brief Internal functions ... incomplete-documentation
199
200 These functions have been made public as part of the design, but they are suggested for internal use
201 or by particularly knowledgeable users for specialized tools or applications.
202
203 \internal We could not make these private because they are required by user for special purposes. And
204 it would be unwieldy to have many of the internal classes in ROSE be explicitly defined as friends.
205
206 */
207
208 // MS: 02/12/02 container of pointers to AST successor nodes used in the traversal
209 // overridden in every class by *generated* implementation
211 virtual std::vector<SgNode*> get_traversalSuccessorContainer();
212 // MS: 06/28/02 container of names of variables or container indices
213 // used used in the traversal to access AST successor nodes
214 // overridden in every class by *generated* implementation
217 virtual std::vector<std::string> get_traversalSuccessorNamesContainer();
218
219 // GB (09/25/2007): Functions for index-based access to traversal successors; these are hopefully a lot faster
220 // than all the vector copies. The implementation for these functions is generated for each class.
226 virtual size_t get_childIndex(SgNode *child);
227
228#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
229 // MS: 08/16/2002 method for generating RTI information
231 virtual RTIReturnType roseRTI();
232#endif
233 /* */
234
235
236
237 /* name Deprecated Functions
238 \brief Deprecated functions ... incomplete-documentation
239
240 These functions have been deprecated from use.
241 */
242 /* */
243
245 virtual const char* sage_class_name() const ROSE_DEPRECATED_FUNCTION;
246
247 // JJW (10/16/2008): Changed to a single function in Node.code, and put
248 // getVariant() in #if 0 block to prevent confusing Doxygen
249#if 0
251 virtual int variant() const ROSE_DEPRECATED_FUNCTION;
253 // virtual int getVariant() const ROSE_DEPRECATED_FUNCTION;
254#endif
255 /* */
256
257
258
259
260 public:
261 /* name Traversal Support Functions
262 \brief Traversal support functions ... incomplete-documentation
263
264 These functions have been made public as part of the design, but they are suggested for internal use
265 or by particularly knowledgable users for specialized tools or applications.
266 */
267 /* */
268
269 // DQ (11/26/2005): Support for visitor pattern mechanims
270 // (inferior to ROSE traversal mechanism, experimental).
274
275 /* DXN (08/09/2010): support for the classic visitor pattern done in GoF */
277 virtual void accept (ROSE_VisitorPattern & visitor);
278
279 // DQ (12/26/2005): Support for traversal based on the memory pool
283
287
288 // DQ (2/9/2006): Added to support traversal over single representative of each IR node
289 // This traversal helps support internal tools that call static member functions.
290 // note: this function operates on the memory pools.
294 /* */
295
296 public:
297 /* NodeId support functions */
299 static SgNode* getNodeByNodeId(VariantT variantT, size_t poolIdx, size_t itemIdx);
302 static SgNode* getNodeByNodeIdInternal(size_t poolIdx, size_t itemIdx);
305 static std::string getNodeIdString(SgNode* sgnode);
306 static std::string getNodeIdStringInternal(SgNode* sgnode);
307
308 public:
309 /* name Memory Allocation Functions
310 \brief Memory allocations functions ... incomplete-documentation
311
312 These functions have been made public as part of the design, but they are suggested for internal use
313 or by particularly knowledgable users for specialized tools or applications.
314 */
315 /* */
316
327 virtual bool isInMemoryPool();
328
340
341 // DQ (4/30/2006): Modified to be a const function.
356 virtual std::vector<std::pair<SgNode*,std::string> > returnDataMemberPointers() const;
357
368
380 virtual long getChildIndex( SgNode* childNode ) const;
381
382 // DQ (9/2/2015): Since this function is generated by ROSETTA, we can't define the
383 // comment here (changed to be a C style comment and not be a doxygen comment).
384 /* \brief Constructor for use by AST File I/O Mechanism
385
386 This constructor permits the IR node to be rebuilt from the contiguously arranged data in memory
387 which obtained via fast binary file I/O from disk.
388 */
389 // SgNode( SgNodeStorageClass& source );
390
391
392
393
394
395 // JH (10/24/2005): methods added to support the ast file IO
396 private:
397
398 /* name AST Memory Allocation Support Functions
399 \brief Memory allocations support....
400
401 These functions handle the low leve support of the memory allocation scheme which permits IR nodes to be allocated
402 in large contiguous blocks to reduce memory fragmentation, improve performance, support specialized access (AST traversals),
403 and support the AST File I/O Mechanism.
404 */
405 /* */
406
407 /* JH (10/24/2005): Two typedefs. The TestType notes the type every pointer is cast to before
408 we compare them. Since I had several problems with this, I decided to make a typdef to ensure
409 that I use the same type everywhere, if any changes are made. THe second one declares the type
410 (actually unsigned long) where teh pointer address gets converted to. On 64 bit platforms this
411 might got changed, but unfortunatly, the return types are still unsigned longs. There exists
412 a correspinding one in the AST_FILE_IO class!
413 */
414 // DQ (9/2/2015): This typedef is no longer used, we can't define the
415 // comment here (changed to be a C style comment and not be a doxygen comment).
416 /* \brief Typedef used for low level memory access.
417 */
418 // typedef unsigned char* TestType;
419
420 // DQ (9/2/2015): This typedef is no longer used, we can't define the
421 // comment here (changed to be a C style comment and not be a doxygen comment).
422 /* \brief Typedef used to hold memory addresses as values.
423 */
424 // typedef unsigned long AddressType;
425
426
427
428 // necessary, to have direct access to the p_freepointer and the private methods !
430 friend class AST_FILE_IO;
431
433 friend class SgNodeStorageClass;
434
436 friend class AstSpecificDataManagingClass;
437
439 friend class AstSpecificDataManagingClassStorageClass;
440 public:
442 SgNode( const SgNodeStorageClass& source );
443
444 // private: // JJW hack
445 /*
446 name AST Memory Allocation Support Variables
447 Memory allocations support variables
448
449 These variables handle the low level support of the memory allocation scheme which permits IR nodes to be allocated
450 in large contiguous blocks to reduce memory fragmentation, improve performance, support specialized access (AST traversals),
451 and support the AST File I/O Mechanism.
452 */
453 /* */
454
455 public:
456
457 // DQ (11/21/2009): Added function to add new Regular Expression attributes and return pointer
458 // to current node (so that it will work cleanly with build functions to specify patterns).
459 // virtual SgNode* addRegExpAttribute();
466
467#ifndef _MSC_VER
468// Rasmussen (04/17/2019): Support for ATerms has been deprecated as it is no longer needed
469// and likely never fully implemented nor tested. Files remain in the src tree but are no
470// longer built.
471#define BUILD_ATERM_SUPPORT 0
472 #if BUILD_ATERM_SUPPORT
473 #ifdef ROSE_USE_ROSE_ATERM_SUPPORT
474 // DQ (10/4/2014): Adding ATerm support to ROSE.
484 // Rasmussen (1/7/2019): Added to kill warning messages of overridden virtual function
485 virtual ATerm generate_ATerm();
486
488 virtual void generate_ATerm_Annotation(ATerm & term);
489 #endif
490 #endif // BUILD_ATERM_SUPPORT
491#endif
492 // These can't be virtual functions since we don't yet know what IR node to build (until we have read the aterm).
493 // virtual generate_AST(ATerm & term);
494 // virtual void read_ATerm_Annotation(ATerm & term);
495
496// *** COMMON CODE SECTION ENDS HERE ***
497
498
499// End of memberFunctionString
500// Start of memberFunctionString
501/* #line 68 "/workspace/src/ROSETTA/Grammar/Node.code" */
502
503 public:
504
511 void set_isModified( bool isModified );
512
517 void set_containsTransformation( bool containsTransformation );
518
519
525 bool get_isModified() const;
526
532
533#if 0
534 // DQ (5/2/2021): I think we need a flag to record when a transformation is contained directly in the current file.
539 void set_containsTransformationRelativeToNodeFile( bool containsTransformationRelativeToNodeFile );
540
545 bool get_containsTransformationRelativeToNodeFile() const;
546#endif
548 void set_parent ( SgNode* parent );
549
552
553 // DQ (3/4/2022): Added access function for p_parent for debugging.
556
558 bool isChild ( SgNode* node ) const;
559
560 // DQ (4/4/2006): Added optional parameter to customize unparsing
562 // virtual std::string unparseToString(SgUnparse_Info* info = NULL) const;
563 // Jeremiah (11/9/2007): The default value is not recognized by gdb.
564 virtual std::string unparseToString(SgUnparse_Info* info) const;
565
566 // DQ (9/6/2010): Move this to the source file (we want to eliminate function definitions in header files).
567 // The existence of this function addresses a bug in gdb (see comment from Jeremiah (11/9/2007) above).
568 // inline std::string unparseToString() const { return this->unparseToString(NULL); }
569 std::string unparseToString() const;
570
573
582 static std::vector<std::string> buildCommandLineToSubstituteTransformationFile( const std::vector<std::string>& argv, std::string newFileName );
583
584 // JJW (10/16/2008): Replace variant() by variantT() and a cast (the
585 // numbers are the same, but the enumerator names are different)
586 int variant() const ROSE_DEPRECATED_FUNCTION {return (int)this->variantT();}
587
588 // AS (10/22/2007): build function to return class hierachy subtree of a VariantT
589 static std::vector<VariantT> getClassHierarchySubTreeFunction( VariantT v);
590 static void getClassHierarchySubTreeFunction( VariantT v, std::vector<VariantT>&);
591
597 bool get_isVisited () const ROSE_DEPRECATED_FUNCTION;
598
603 void set_isVisited ( bool isVisited ) ROSE_DEPRECATED_FUNCTION;
604
609 static std::map<SgNode*,std::string> & get_globalMangledNameMap();
610
613 static void clearGlobalMangledNameMap();
614
620 static std::map<std::string, uint64_t> & get_shortMangledNameCache();
621
622
628 static std::map<SgNode*,std::string> & get_globalQualifiedNameMapForNames();
629
635 static void set_globalQualifiedNameMapForNames ( const std::map<SgNode*,std::string> & X );
636
643 static std::map<SgNode*,std::string> & get_globalQualifiedNameMapForTypes();
644
651 static void set_globalQualifiedNameMapForTypes ( const std::map<SgNode*,std::string> & X );
652
653 // DQ (3/13/2019): Added name qualification support for references to types than can embed many types.
660 static std::map<SgNode*,std::map<SgNode*,std::string> > & get_globalQualifiedNameMapForMapsOfTypes();
661
662 // DQ (3/13/2019): Added name qualification support for references to types than can embed many types.
669 static void set_globalQualifiedNameMapForMapsOfTypes ( const std::map<SgNode*,std::map<SgNode*,std::string> > & X );
670
680 static std::map<SgNode*,std::string> & get_globalQualifiedNameMapForTemplateHeaders();
681
686 static void set_globalQualifiedNameMapForTemplateHeaders ( const std::map<SgNode*,std::string> & X );
687
694 static std::map<SgNode*,std::string> & get_globalTypeNameMap();
695
701 static void set_globalTypeNameMap ( const std::map<SgNode*,std::string> & X );
702
703 /* name Persistant Attribute Mechanism
704
705 This is the persistant attribute mechanism for attaching attributed to IR nodes across
706 multiple passes. Note that these attributes are persistant in that they are preserved
707 if the AST is written out to a file and read in from a file. However, virtual function
708 in the user-defined class derived from the AstAttribute must be defined for the attribute
709 to be defined across the boundary of File I/O (simple pack and unpack functions). More
710 sophisticated mechanisms are available within the AstAttributeMechanism object
711 (e.g iterating though attributes, etc; get_attributeMechanism() is available if direct
712 access is required, however mostly only internal tools use this lower level support).
713
714 \internal This used to be a public data member, but has been changed to be a protected
715 pointer instead. The functional interface of the AstAttributeMechanism is presevered
716 but some of the names and the syntax for calling the interface have changed. The
717 pointer to the AstAttributeMechanism is now generated by ROSETTA.
718 */
719 /* */
721 virtual void addNewAttribute(std::string s,AstAttribute* a);
723 virtual AstAttribute* getAttribute(std::string s) const;
725 virtual void updateAttribute(std::string s,AstAttribute* a); // formerly called: replace in AstAttributeMechanism
730 virtual void setAttribute(std::string s,AstAttribute* a);
732 virtual void removeAttribute(std::string s);
734 virtual bool attributeExists(std::string s) const;
736 virtual int numberOfAttributes() const;
737
745 virtual AstAttributeMechanism* get_attributeMechanism() const;
752 virtual void set_attributeMechanism(AstAttributeMechanism* a);
753 /* */
754
755#if ALT_FIXUP_COPY
756 /* name AST Copy Support Functions
757
758 Support for IR node specific fixup of copy operation.
759 This function helps reset scopes and build untraversed parts of the
760 AST that are difficult to have be constructed using the automatically
761 generated copy functions.
762
763 \implementation These functions are used internally inside the AST copy mechanism.
764 The public interface for this functionality is given below this section.
765 */
766 /* */
767 virtual void fixupCopy_scopes (SgNode* copy, SgCopyHelp & help) const;
768 virtual void fixupCopy_symbols (SgNode* copy, SgCopyHelp & help) const;
769 virtual void fixupCopy_references (SgNode* copy, SgCopyHelp & help) const;
770 /* */
771#else
772 virtual void fixupCopy(SgNode* copy, SgCopyHelp & help) const;
773#endif
774
775 /* name Source Position Information
776 \brief Support for source code position information of all IR nodes.
777
778 These are the virtual function definitions, they are overloaded for SgLocatedNode
779 and a few of the SgSupport IR nodes.
780 */
781 /* */
790 virtual Sg_File_Info* get_file_info(void) const { return nullptr; }
791
795 virtual Sg_File_Info* get_startOfConstruct(void) const {return nullptr;}
796
800 virtual Sg_File_Info* get_endOfConstruct(void) const { return nullptr; }
801 /* */
802
803 /* name Control flow graph public functions
804
805 These functions return control flow graph nodes for various positions
806 around a construct. */
807 /* */
808
809#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
814#endif
815
816#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
817 /* name Control flow graph view helper functions
818
819 These functions are used internally inside the control flow graph
820 view code. The public interface for this functionality is given
821 below this section. */
822 /* */
823
825 virtual unsigned int cfgIndexForEnd() const;
826
829 virtual bool cfgIsIndexInteresting(unsigned int index) const;
830
832 virtual unsigned int cfgFindChildIndex(SgNode* n);
833
835 virtual unsigned int cfgFindNextChildIndex(SgNode* n);
836
838 virtual std::vector<VirtualCFG::CFGEdge> cfgOutEdges(unsigned int index = false);
839
841 virtual std::vector<VirtualCFG::CFGEdge> cfgInEdges(unsigned int index = false);
842#endif
843 /* */
844
845 // DQ (1/31/2006): These must be built to be static access member functions (so they can't be built by ROSETTA).
846 /* name Function Type Information
847 Support for global view of function types used in ROSE.
848 */
849 /* */
853 static void set_globalFunctionTypeTable(SgFunctionTypeTable* globalFunctionTypeTable);
854 /* */
855
856 // DQ (7/22/2010): Added seperate type table to support construction of unique types.
860 static void set_globalTypeTable(SgTypeTable* globalTypeTable);
861
862 protected:
863 static std::vector<std::tuple<unsigned char*, unsigned, VariantT>> all_pools;
864 public:
865 static VariantT variantFromPool(SgNode const * n);
866
867 /* \brief Mangled name cache for improved performance of mangled name generation
868 This mangle name caching is implemented to support better performance.
869 */
870 // static std::map<SgNode*,std::string> & get_globalMangledNameMap();
871
879
888
889 protected:
890
898
899 private:
900 // Make the copy constructor private (to avoid it being used)
901 /* We have to make the copy constructor available so that the SgUnparse_Info
902 copy constructor can access it, I'm not clear if this is a good idea.
903 */
904 // SgNode(const SgNode &); /* private so it can't be used. */
905
907 SgNode & operator= (const SgNode &) = delete;
908
909public:
923 template<class T>
924 static typename std::enable_if<std::is_base_of<SgNode, T>::value, T*>::type
926 auto node = new T;
927 node->set_parent(parent);
928 return node;
929 }
930
940 template<class T>
941 T* initParentPointer(T *child, SgNode *parent) {
942 ASSERT_not_null(parent);
943 if (child) {
944#ifndef NDEBUG
945 auto toString = [](SgNode *node) {
946 if (node) {
947 return (boost::format("(%s*)%p") % node->class_name() % node).str();
948 } else {
949 return std::string("nullptr");
950 }
951 };
952
953 ASSERT_require2(child->get_parent() == nullptr,
954 "child " + toString(child) +
955 " cannot be inserted into " + toString(parent) +
956 " because it is already a child of " + toString(child->get_parent()));
957#endif
958 child->set_parent(this);
959 }
960 return child;
961 }
962
999 template<class T>
1000 typename std::enable_if<
1001 std::is_pointer<T>::value,
1002 void>::type
1003 changeChildPointer(T& edge, T const& child) {
1004#ifndef NDEBUG
1005 auto toString = [](SgNode *node) {
1006 if (node) {
1007 return (boost::format("(%s*)%p") % node->class_name() % node).str();
1008 } else {
1009 return std::string("nullptr");
1010 }
1011 };
1012#endif
1013
1014 if (child != edge) {
1015 // If there is an old child, check that it has the correct parent and then remove it.
1016 if (edge) {
1017 ASSERT_require2(edge->get_parent() == this,
1018 "node " + toString(edge) +
1019 " is a child of " + toString(this) +
1020 " but has wrong parent " + toString(edge->get_parent()));
1021 edge->set_parent(nullptr);
1022 edge = nullptr;
1023 }
1024
1025 // If there is a new child, check its parent pointer and then insert it.
1026 if (child) {
1027 ASSERT_require2(child->get_parent() == nullptr,
1028 "node " + toString(child) +
1029 " is to be a child of " + toString(this) +
1030 " but is already a child of " + toString(child->get_parent()));
1031 child->set_parent(this);
1032 edge = child;
1033 }
1034 }
1035 }
1036
1037 // This gets called for non-pointers, which is the situation for nodes that are only lists of other nodes. We're currently
1038 // not checking them because the ROSETTA-generated API has too many ways to get around this check, most of which make it
1039 // impossible to enforce constraints regarding the parent/child consistency. For example:
1040 //
1041 // node->children().clear(); // removes a whole bunch of children but doesn't clear their parent pointers
1042 // node->children()[i] = child; // changes the ith child, but doesn't clear the previous ith child's parent pointer
1043 // for (auto &tmp: node->children()) tmp = nullptr; // changes each child but doesn't clear parent pointers
1044 // ad nausiam...
1045 template<class T>
1046 typename std::enable_if<
1047 !std::is_pointer<T>::value,
1048 void>::type
1049 changeChildPointer(T& edge, T const& child) {
1050 edge = child;
1051 }
1055private:
1056 // This is called by the debugSerializationBegin and debugSerializationEnd that are in turn called at the beginning and end of
1057 // each AST node's serialization function. The implementation below uses two counters: classSerializationDepth shared by all
1058 // instances of this class, and objectSerializationDepth_ which is a per-instance counter. The relationship of these two
1059 // counters can tell us how deeply nested these recursive calls are, and which of those recursion levels are due to traversing
1060 // through the base classes versus traversing through data members. In the output, we use one character of indentation per
1061 // recursion level, with spaces (' ') representing recursion due to data members and dots ('.') representing recursion due to
1062 // base classes.
1063#if 0
1064 // Debugging version
1065 size_t objectSerializationDepth_ = 0; // incremented as we traverse through base classes
1066 void debugSerializationHelper(const char *className, bool isBegin) {
1067 static size_t classSerializationDepth = 0; // incremented by both base classes and data members
1068 if (isBegin) {
1069 ASSERT_require(classSerializationDepth >= objectSerializationDepth_);
1070 const size_t memberTraversalDepth = classSerializationDepth - objectSerializationDepth_;
1071 std::cerr <<"serializing: " <<std::string(memberTraversalDepth, ' ') <<std::string(objectSerializationDepth_, '.')
1072 <<className <<" " <<this <<"\n";
1073 ++classSerializationDepth;
1074 ++objectSerializationDepth_;
1075 } else {
1076 ASSERT_require2(classSerializationDepth > 0, className);
1077 ASSERT_require2(objectSerializationDepth_ > 0, className);
1078 --classSerializationDepth;
1079 --objectSerializationDepth_;
1080 }
1081 }
1082#else
1083 // Production version
1084 void debugSerializationHelper(const char*, bool) {}
1085#endif
1086
1087protected:
1117 virtual void destructorHelper() {}
1118
1119protected:
1127 virtual void debugSerializationBegin(const char *className) {
1128 debugSerializationHelper(className, true);
1129 }
1130 virtual void debugSerializationEnd(const char *className) {
1131 debugSerializationHelper(className, false);
1132 }
1135 public:
1136
1137
1138
1139// End of memberFunctionString
1140
1141
1142
1143
1144 public:
1145 SgNode* get_freepointer() const;
1146 void set_freepointer(SgNode* freepointer);
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158 public:
1159 virtual ~SgNode();
1160
1161
1162 public:
1163 SgNode();
1164
1165 protected:
1166// Start of memberFunctionString
1167SgNode* p_parent;
1168
1169// End of memberFunctionString
1170// Start of memberFunctionString
1171bool p_isModified;
1172
1173// End of memberFunctionString
1174// Start of memberFunctionString
1175bool p_containsTransformation;
1176
1177// End of memberFunctionString
1178// Start of memberFunctionString
1179SgNode* p_freepointer;
1180
1181// End of memberFunctionString
1182// Start of memberFunctionString
1183static SgFunctionTypeTable* p_globalFunctionTypeTable;
1184
1185// End of memberFunctionString
1186// Start of memberFunctionString
1187static SgTypeTable* p_globalTypeTable;
1188
1189// End of memberFunctionString
1190// Start of memberFunctionString
1191static std::map<SgNode*,std::string> p_globalMangledNameMap;
1192
1193// End of memberFunctionString
1194// Start of memberFunctionString
1195static std::map<std::string, uint64_t> p_shortMangledNameCache;
1196
1197// End of memberFunctionString
1198// Start of memberFunctionString
1199static std::map<SgNode*,std::string> p_globalQualifiedNameMapForNames;
1200
1201// End of memberFunctionString
1202// Start of memberFunctionString
1203static std::map<SgNode*,std::string> p_globalQualifiedNameMapForTypes;
1204
1205// End of memberFunctionString
1206// Start of memberFunctionString
1207static std::map<SgNode*,std::string> p_globalQualifiedNameMapForTemplateHeaders;
1208
1209// End of memberFunctionString
1210// Start of memberFunctionString
1211static std::map<SgNode*,std::string> p_globalTypeNameMap;
1212
1213// End of memberFunctionString
1214// Start of memberFunctionString
1215static std::map<SgNode*,std::map<SgNode*,std::string> > p_globalQualifiedNameMapForMapsOfTypes;
1216
1217// End of memberFunctionString
1218
1222 friend struct Rose::Traits::generated::describe_field_t<SgNode, bool,&SgNode::p_containsTransformation>;
1224
1225/* #line 21 "/workspace/src/ROSETTA/Grammar/grammarClassDeclarationMacros.macro" */
1226
1227
1228 };
1229#endif
1230
1231// postdeclarations for SgNode
1232
1233/* #line 1234 "../../../src/frontend/SageIII//SgNode.h" */
1234
1235/* #line 27 "/workspace/src/ROSETTA/Grammar/grammarClassDeclarationMacros.macro after subst for $POSTDECLARATIONS" */
1236
1237/* #line 28 "/workspace/src/ROSETTA/Grammar/grammarClassDeclarationMacros.macro" */
1238
1239
1240/* #line 1241 "../../../src/frontend/SageIII//SgNode.h" */
1241
1242#endif // ROSE_SgNode_H
1243
Class holding static data and functions supporting File I/O.
Definition AST_FILE_IO.h:19
Stores named attributes in Sage IR nodes.
Base class for all IR node attribute values.
Attribute containing a regex expression as a string.
For preprocessing information including source comments, include , if, define, etc.
Base class for machine instructions.
Supporting class from copy mechanism within ROSE.
Definition sageCopy.h:26
This class represents the function type table (stores all function types so that they can be shared i...
This class represents the base class for all IR nodes within Sage III.
std::string unparseToCompleteString()
This function unparses the AST node (including comments and white space)
SgNode * p_parent
This is the pointer to the parent IR node in the AST.
virtual Sg_File_Info * get_startOfConstruct(void) const
New function interface for Sg_File_Info data stores starting location of contruct (typically the open...
Definition SgNode.h:795
virtual size_t get_numberOfTraversalSuccessors()
return number of children in the traversal successor list
virtual VariantT variantT() const
returns new style SageIII enum values
ROSE_DLL_API friend const SgNode * isSgNode(const SgNode *s)
Casts pointer from base class to derived class (for const pointers)
static SgTypeTable * get_globalTypeTable()
Access function for symbol table specific to non-function types.
virtual RTIReturnType roseRTI()
return C++ Runtime-Time-Information
virtual Sg_File_Info * get_endOfConstruct(void) const
New function interface for Sg_File_Info data stores ending location of contruct (typically the closin...
Definition SgNode.h:800
virtual std::vector< std::string > get_traversalSuccessorNamesContainer()
container of names of variables or container indices used used in the traversal to access AST success...
bool get_containsTransformation() const
Acess function for containsTransformation flag.
virtual std::vector< VirtualCFG::CFGEdge > cfgInEdges(unsigned int index=false)
Find the in edges of a CFG node – internal version.
void set_isModified(bool isModified)
All nodes in the AST contain a isModified flag used to track changes to the AST.
virtual std::vector< SgNode * > get_traversalSuccessorContainer()
container of pointers to AST successor nodes used in the traversal overridden in every class by gener...
virtual void debugSerializationEnd(const char *className)
Called by generated serializers.
Definition SgNode.h:1130
SgNode(const SgNodeStorageClass &source)
IR node constructor to support AST File I/O.
static std::string getNodeIdString(SgNode *sgnode)
compute the NodeId for a particular SgNode*.
virtual bool isInMemoryPool()
FOR INTERNAL USE This is used in internal tests to verify that all IR nodes are allocated from the he...
VirtualCFG::CFGNode cfgForEnd()
Returns the CFG node for just after this AST node.
std::enable_if< std::is_pointer< T >::value, void >::type changeChildPointer(T &edge, T const &child)
Set a child edge in a tree to point to a specific child.
Definition SgNode.h:1003
void set_parent(SgNode *parent)
All nodes in the AST contain a reference to a parent node.
virtual void processDataMemberReferenceToPointers(ReferenceToPointerHandler *)
FOR INTERNAL USE Processes pairs of references to SgNode* and strings for use in AST tools
SgNode * get_parent() const
Access function for parent node.
bool isChild(SgNode *node) const
Query function for if the input IR nodes is a child of the current IR node.
virtual std::string class_name() const
returns a string representing the class name
int numberOfNodesInSubtree()
Computes the number of nodes in the defined subtree of the AST.
virtual long getChildIndex(SgNode *childNode) const
FOR INTERNAL USE Returns a unique index value for the childNode in the list of children at this IR no...
VirtualCFG::CFGNode cfgForBeginning()
Returns the CFG node for just before this AST node.
virtual std::string unparseToString(SgUnparse_Info *info) const
This function unparses the AST node (excluding comments and unnecessary white space)
virtual unsigned int cfgFindChildIndex(SgNode *n)
Find the index of n in this node's CFG children.
virtual size_t get_childIndex(SgNode *child)
index-based access to traversal successors by child node
virtual void debugSerializationBegin(const char *className)
Called by generated serializers.
Definition SgNode.h:1127
static void set_globalTypeTable(SgTypeTable *globalTypeTable)
Access function for symbol table specific to non-function types.
static std::vector< std::string > buildCommandLineToSubstituteTransformationFile(const std::vector< std::string > &argv, std::string newFileName)
Command line support for this compilation The command line is saved as a static variable so that it w...
virtual unsigned int cfgIndexForEnd() const
Determine the CFG index for the end of this construct.
static std::enable_if< std::is_base_of< SgNode, T >::value, T * >::type createAndParent(SgNode *parent)
Allocate and return a new node after setting its parent.
Definition SgNode.h:925
static void visitRepresentativeNode(ROSE_VisitTraversal &visit)
FOR INTERNAL USE Support for type-based traversal.
virtual void checkDataMemberPointersIfInMemoryPool()
FOR INTERNAL USE This is used in internal tests to verify that all IR nodes are allocated from the he...
static size_t numberOfNodes()
Returns the total number of IR nodes of this type.
bool get_isModified() const
Acess function for isModified flag.
ROSE_DLL_API friend SgNode * isSgNode(SgNode *s)
Casts pointer from base class to derived class.
int depthOfSubtree()
Computes the depth of the current defined subtree of the AST.
static SgFunctionTypeTable * get_globalFunctionTypeTable()
Access function for symbol table specific to function types.
virtual void accept(ROSE_VisitorPattern &visitor)
support for the classic visitor pattern done in GoF
virtual Sg_File_Info * get_file_info(void) const
File information containing filename, line number, column number, and if the SgNode is a part of a ne...
Definition SgNode.h:790
virtual std::vector< VirtualCFG::CFGEdge > cfgOutEdges(unsigned int index=false)
Find the out edges of a CFG node – internal version.
virtual SgNode * get_traversalSuccessorByIndex(size_t idx)
index-based access to traversal successors by index number
static void traverseMemoryPoolVisitorPattern(ROSE_VisitorPattern &visitor)
FOR INTERNAL USE Support for visitor pattern.
std::enable_if<!std::is_pointer< T >::value, void >::type changeChildPointer(T &edge, T const &child)
Set a child edge in a tree to point to a specific child.
Definition SgNode.h:1049
void executeVisitorMemberFunction(ROSE_VisitorPattern &visitor)
FOR INTERNAL USE Support for visitor pattern.
static SgNode * getNodeByNodeId(VariantT variantT, size_t poolIdx, size_t itemIdx)
Find a node by its variant type, pool index, and item index.
virtual unsigned int cfgFindNextChildIndex(SgNode *n)
Find the index just after n in this node's CFG children.
static size_t memoryUsage()
Returns the size in bytes of the total memory allocated for all IR nodes of this type.
static void traverseMemoryPoolNodes(ROSE_VisitTraversal &visit)
FOR INTERNAL USE Support for visitor pattern over all IR nodes by type of IR node.
virtual void post_construction_initialization()
Final initialization for constructors This function is called at the end of generated constructors to...
T * initParentPointer(T *child, SgNode *parent)
Generated for tree edge data member initializations.
Definition SgNode.h:941
virtual std::vector< std::pair< SgNode *, std::string > > returnDataMemberPointers() const
FOR INTERNAL USE Returns STL vector of pairs of SgNode* and strings for use in AST tools
static void set_globalFunctionTypeTable(SgFunctionTypeTable *globalFunctionTypeTable)
Access function for symbol table specific to function types.
virtual const char * sage_class_name() const
void set_containsTransformation(bool containsTransformation)
Many nodes can hide other AST nodes and we need to track when outer nodes contain modified nodes even...
bool p_isModified
Records if IR node has been modified (data members reset).
bool get_isVisited() const
DOCS IN HEADER: Access function for p_isVisited flag used previously by the AST traversals.
static SgNode * getNodeByNodeIdInternal(size_t poolIdx, size_t itemIdx)
FOR INTERNAL USE Find an SgNode from its memory pool and location therin.
SgNode * p_freepointer
This is the pointer to the chain of previously freed objects.
virtual bool cfgIsIndexInteresting(unsigned int index) const
Determine whether a particular CFG node index is "interesting" for this kind of node.
SgNode * addRegExpAttribute(std::string s, AstRegExAttribute *a)
Support for AST matching using regular expression.
SgNode * get_raw_parent() const
Access function for direct access to uncomputed value of parent node.
virtual void destructorHelper()
This gets called by all Rosebud-generated destructors.
Definition SgNode.h:1117
This class represents the location of the code associated with the IR node in the original source cod...
A node in the control flow graph.
Definition virtualCFG.h:70
The ROSE library.
void copy(const Word *src, const BitRange &srcRange, Word *dst, const BitRange &dstRange)
Copy some bits.