ROSE 0.11.145.328
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 <sageContainer.h>
32#include <boost/format.hpp>
33
34#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
35#include <boost/serialization/access.hpp>
36#include <boost/serialization/base_object.hpp>
37#include <boost/serialization/map.hpp>
38#include <boost/serialization/set.hpp>
39#include <boost/serialization/vector.hpp>
40#include <boost/serialization/version.hpp>
41#endif
42
43#include <Sawyer/CommandLine.h>
44#include <Sawyer/Interval.h>
45#include <Sawyer/IntervalSet.h>
46
47#include "processSupport.h"
48#define __builtin_constant_p(exp) (0)
49
50#ifdef ROSE_ENABLE_BINARY_ANALYSIS
51#include <Rose/BinaryAnalysis/AddressSet.h>
52#include <Rose/BinaryAnalysis/RelativeVirtualAddress.h>
53#include <Rose/BinaryAnalysis/AddressInterval.h>
54#include <Rose/BinaryAnalysis/AddressIntervalSet.h>
55#include <rose_extent.h> // deprecated
56#include <Rose/BinaryAnalysis/RegisterDescriptor.h>
57#include <Rose/BinaryAnalysis/InstructionMap.h>
58#include <ROSE_NELMTS.h>
59#endif
60
61#include <Rose/Constants.h>
62#include <sageHash.h>
63#include <sageTraversal.h>
64#include <sageRti.h>
65#include <sageCopy.h>
66#include <sageMemory.h>
67#include <Cxx_GrammarVariants.h>
68#include <Cxx_GrammarStorageClasses.h>
69#include <virtualCFG.h>
70
71namespace Rose { namespace Traits { namespace generated { template <typename NodeT> struct describe_node_t; } } }
72namespace Rose { namespace Traits { namespace generated { template <typename NodeT, typename FieldT, FieldT NodeT::* fld_ptr> struct describe_field_t; } } }
73
74#ifdef ROSE_ENABLE_BINARY_ANALYSIS
75// Version numbers for SgAsm* nodes. Used for backward compatibility. */
76BOOST_CLASS_VERSION(SgAsmInstruction, 1);
77#endif
78
81class AstAttribute;
84
85// DQ (3/18/2006): Forward declarations of classes used to control and tailor the code generation.
86class UnparseDelegate;
87class UnparseFormatHelp;
88
89// DQ (4/32/2006): g++ 4.0.2 requires a forward declaration for this (a friend class declaration is not sufficient!)
90class AstSpecificDataManagingClassStorageClass;
91
92
93
94/* #line 13 "/workspace/src/ROSETTA/Grammar/grammarClassDeclarationMacros.macro after subst for $PREDECLARATIONS" */
95
96/* #line 14 "/workspace/src/ROSETTA/Grammar/grammarClassDeclarationMacros.macro" */
97
98#if 1
99// Class Definition for SgNode
100class ROSE_DLL_API SgNode
101 {
102 public:
103
104
105/* #line 106 "../../../src/frontend/SageIII//SgNode.h" */
106
107 virtual SgNode* copy ( SgCopyHelp& help) const;
108// Start of memberFunctionString
109/* #line 1 "/workspace/src/ROSETTA/Grammar/Common.code" */
110
111// *** COMMON CODE SECTION BEGINS HERE ***
112
113 public:
114
115 // DQ (3/25/3006): I put this back in because it had the logic for where the copy function required
116 // and not required which is required to match the other aspects of the copy mechanism code generation.
117 // Specifically it is a problem to declare the copy function everywhere because it is not implemented
118 // for the SgSymbol IR nodes. I'm not clear why it is not implemented for these IR nodes.
119 /* \brief Copies AST (whole subtree, depending on the SgCopyHelp class */
120 // virtual SgNode* copy ( const SgCopyHelp & help) const;
121
123 virtual std::string class_name() const;
124
126 virtual VariantT variantT() const; // MS: new variant used in tree traversal
127
129 // King84 (2010.08.16): Moved this to an enum to save space, since it's only used at compiler-time anyway.
130 // static const VariantT static_variant = V_SgNode;
131 enum { static_variant = V_SgNode };
132
133 /* the generated cast function */
135 ROSE_DLL_API friend SgNode* isSgNode( SgNode * s );
136
138 ROSE_DLL_API friend const SgNode* isSgNode( const SgNode * s );
139
140 // ******************************************
141 // * Memory Pool / New / Delete
142 // ******************************************
143
144 public:
146 static const unsigned pool_size; //
148 static std::vector<unsigned char *> pools; //
150 static SgNode * next_node; //
151
153 static unsigned long initializeStorageClassArray(SgNodeStorageClass *); //
154
156 static void clearMemoryPool(); //
157 static void deleteMemoryPool(); //
158
160 static void extendMemoryPoolForFileIO(); //
161
163 static SgNode * getPointerFromGlobalIndex(unsigned long); //
165 static SgNode * getPointerFromGlobalIndex(AstSpecificDataManagingClass *, unsigned long); //
166
168 static unsigned long getNumberOfValidNodesAndSetGlobalIndexInFreepointer(unsigned long); //
170 static void resetValidFreepointers(); //
172 static unsigned long getNumberOfLastValidPointer(); //
173
174
175#if defined(INLINE_FUNCTIONS)
177 inline void *operator new (size_t size);
178#else
180 void *operator new (size_t size);
181#endif
183 void operator delete (void* pointer, size_t size);
184
185 // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
186 void operator delete (void* pointer)
187 {
188 // This is the generated delete operator...
189 SgNode::operator delete (pointer,sizeof(SgNode));
190 }
191
193 static size_t numberOfNodes();
194
196 static size_t memoryUsage();
197
198 // End of scope which started in IR nodes specific code
199 /* */
200
201 /* name Internal Functions
202 \brief Internal functions ... incomplete-documentation
203
204 These functions have been made public as part of the design, but they are suggested for internal use
205 or by particularly knowledgeable users for specialized tools or applications.
206
207 \internal We could not make these private because they are required by user for special purposes. And
208 it would be unwieldy to have many of the internal classes in ROSE be explicitly defined as friends.
209
210 */
211
212 // MS: 02/12/02 container of pointers to AST successor nodes used in the traversal
213 // overridden in every class by *generated* implementation
215 virtual std::vector<SgNode*> get_traversalSuccessorContainer() const;
216 // MS: 06/28/02 container of names of variables or container indices
217 // used used in the traversal to access AST successor nodes
218 // overridden in every class by *generated* implementation
221 virtual std::vector<std::string> get_traversalSuccessorNamesContainer() const;
222
223 // GB (09/25/2007): Functions for index-based access to traversal successors; these are hopefully a lot faster
224 // than all the vector copies. The implementation for these functions is generated for each class.
226 virtual size_t get_numberOfTraversalSuccessors() const;
228 virtual SgNode *get_traversalSuccessorByIndex(size_t idx) const;
230 virtual size_t get_childIndex(SgNode *child) const;
231
232#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
233 // MS: 08/16/2002 method for generating RTI information
235 virtual RTIReturnType roseRTI();
236#endif
237 /* */
238
239
240
241 /* name Deprecated Functions
242 \brief Deprecated functions ... incomplete-documentation
243
244 These functions have been deprecated from use.
245 */
246 /* */
247
249 virtual const char* sage_class_name() const ROSE_DEPRECATED_FUNCTION;
250
251 // JJW (10/16/2008): Changed to a single function in Node.code, and put
252 // getVariant() in #if 0 block to prevent confusing Doxygen
253#if 0
255 virtual int variant() const ROSE_DEPRECATED_FUNCTION;
257 // virtual int getVariant() const ROSE_DEPRECATED_FUNCTION;
258#endif
259 /* */
260
261
262
263
264 public:
265 /* name Traversal Support Functions
266 \brief Traversal support functions ... incomplete-documentation
267
268 These functions have been made public as part of the design, but they are suggested for internal use
269 or by particularly knowledgable users for specialized tools or applications.
270 */
271 /* */
272
273 // DQ (11/26/2005): Support for visitor pattern mechanims
274 // (inferior to ROSE traversal mechanism, experimental).
278
279 /* DXN (08/09/2010): support for the classic visitor pattern done in GoF */
281 virtual void accept (ROSE_VisitorPattern & visitor);
282
283 // DQ (12/26/2005): Support for traversal based on the memory pool
287
291
292 // DQ (2/9/2006): Added to support traversal over single representative of each IR node
293 // This traversal helps support internal tools that call static member functions.
294 // note: this function operates on the memory pools.
298 /* */
299
300 public:
301 /* NodeId support functions */
303 static SgNode* getNodeByNodeId(VariantT variantT, size_t poolIdx, size_t itemIdx);
306 static SgNode* getNodeByNodeIdInternal(size_t poolIdx, size_t itemIdx);
309 static std::string getNodeIdString(SgNode* sgnode);
310 static std::string getNodeIdStringInternal(SgNode* sgnode);
311
312 public:
313 /* name Memory Allocation Functions
314 \brief Memory allocations functions ... incomplete-documentation
315
316 These functions have been made public as part of the design, but they are suggested for internal use
317 or by particularly knowledgable users for specialized tools or applications.
318 */
319 /* */
320
331 virtual bool isInMemoryPool();
332
344
345 // DQ (4/30/2006): Modified to be a const function.
360 virtual std::vector<std::pair<SgNode*,std::string> > returnDataMemberPointers() const;
361
372
384 virtual long getChildIndex( SgNode* childNode ) const;
385
386 // DQ (9/2/2015): Since this function is generated by ROSETTA, we can't define the
387 // comment here (changed to be a C style comment and not be a doxygen comment).
388 /* \brief Constructor for use by AST File I/O Mechanism
389
390 This constructor permits the IR node to be rebuilt from the contiguously arranged data in memory
391 which obtained via fast binary file I/O from disk.
392 */
393 // SgNode( SgNodeStorageClass& source );
394
395
396
397
398
399 // JH (10/24/2005): methods added to support the ast file IO
400 private:
401
402 /* name AST Memory Allocation Support Functions
403 \brief Memory allocations support....
404
405 These functions handle the low leve support of the memory allocation scheme which permits IR nodes to be allocated
406 in large contiguous blocks to reduce memory fragmentation, improve performance, support specialized access (AST traversals),
407 and support the AST File I/O Mechanism.
408 */
409 /* */
410
411 /* JH (10/24/2005): Two typedefs. The TestType notes the type every pointer is cast to before
412 we compare them. Since I had several problems with this, I decided to make a typdef to ensure
413 that I use the same type everywhere, if any changes are made. THe second one declares the type
414 (actually unsigned long) where teh pointer address gets converted to. On 64 bit platforms this
415 might got changed, but unfortunatly, the return types are still unsigned longs. There exists
416 a correspinding one in the AST_FILE_IO class!
417 */
418 // DQ (9/2/2015): This typedef is no longer used, we can't define the
419 // comment here (changed to be a C style comment and not be a doxygen comment).
420 /* \brief Typedef used for low level memory access.
421 */
422 // typedef unsigned char* TestType;
423
424 // DQ (9/2/2015): This typedef is no longer used, we can't define the
425 // comment here (changed to be a C style comment and not be a doxygen comment).
426 /* \brief Typedef used to hold memory addresses as values.
427 */
428 // typedef unsigned long AddressType;
429
430
431
432 // necessary, to have direct access to the p_freepointer and the private methods !
434 friend class AST_FILE_IO;
435
437 friend class SgNodeStorageClass;
438
440 friend class AstSpecificDataManagingClass;
441
443 friend class AstSpecificDataManagingClassStorageClass;
444 public:
446 SgNode( const SgNodeStorageClass& source );
447
448 // private: // JJW hack
449 /*
450 name AST Memory Allocation Support Variables
451 Memory allocations support variables
452
453 These variables handle the low level support of the memory allocation scheme which permits IR nodes to be allocated
454 in large contiguous blocks to reduce memory fragmentation, improve performance, support specialized access (AST traversals),
455 and support the AST File I/O Mechanism.
456 */
457 /* */
458
459 public:
460
461 // DQ (11/21/2009): Added function to add new Regular Expression attributes and return pointer
462 // to current node (so that it will work cleanly with build functions to specify patterns).
463 // virtual SgNode* addRegExpAttribute();
470
471#ifndef _MSC_VER
472// Rasmussen (04/17/2019): Support for ATerms has been deprecated as it is no longer needed
473// and likely never fully implemented nor tested. Files remain in the src tree but are no
474// longer built.
475#define BUILD_ATERM_SUPPORT 0
476 #if BUILD_ATERM_SUPPORT
477 #ifdef ROSE_USE_ROSE_ATERM_SUPPORT
478 // DQ (10/4/2014): Adding ATerm support to ROSE.
488 // Rasmussen (1/7/2019): Added to kill warning messages of overridden virtual function
489 virtual ATerm generate_ATerm();
490
492 virtual void generate_ATerm_Annotation(ATerm & term);
493 #endif
494 #endif // BUILD_ATERM_SUPPORT
495#endif
496 // These can't be virtual functions since we don't yet know what IR node to build (until we have read the aterm).
497 // virtual generate_AST(ATerm & term);
498 // virtual void read_ATerm_Annotation(ATerm & term);
499
500// *** COMMON CODE SECTION ENDS HERE ***
501
502
503// End of memberFunctionString
504// Start of memberFunctionString
505/* #line 72 "/workspace/src/ROSETTA/Grammar/Node.code" */
506
507 public:
508
515 void set_isModified( bool isModified );
516
521 void set_containsTransformation( bool containsTransformation );
522
523
529 bool get_isModified() const;
530
536
538 void set_parent ( SgNode* parent );
539
542
543 // DQ (3/4/2022): Added access function for p_parent for debugging.
546
548 bool isChild ( SgNode* node ) const;
549
551 virtual std::string unparseToString(SgUnparse_Info* info) const;
552
553 std::string unparseToString() const;
554
557
566 static std::vector<std::string> buildCommandLineToSubstituteTransformationFile( const std::vector<std::string>& argv, std::string newFileName );
567
568 // JJW (10/16/2008): Replace variant() by variantT() and a cast (the
569 // numbers are the same, but the enumerator names are different)
570 int variant() const ROSE_DEPRECATED_FUNCTION {return (int)this->variantT();}
571
572 // AS (10/22/2007): build function to return class hierachy subtree of a VariantT
573 static std::vector<VariantT> getClassHierarchySubTreeFunction( VariantT v);
574 static void getClassHierarchySubTreeFunction( VariantT v, std::vector<VariantT>&);
575
581 bool get_isVisited () const ROSE_DEPRECATED_FUNCTION;
582
587 void set_isVisited ( bool isVisited ) ROSE_DEPRECATED_FUNCTION;
588
593 static std::map<SgNode*,std::string> & get_globalMangledNameMap();
594
597 static void clearGlobalMangledNameMap();
598
604 static std::map<std::string, uint64_t> & get_shortMangledNameCache();
605
606
612 // DQ (8/11/2025): Adding support for unordered maps for name qualification.
613 // static std::map<SgNode*,std::string> & get_globalQualifiedNameMapForNames();
614 static SgUnorderedMapNodeToString & get_globalQualifiedNameMapForNames();
615
621 // DQ (8/11/2025): Adding support for unordered maps for name qualification.
622 // static void set_globalQualifiedNameMapForNames ( const std::map<SgNode*,std::string> & X );
623 static void set_globalQualifiedNameMapForNames ( const SgUnorderedMapNodeToString & X );
624
631 // DQ (8/11/2025): Adding support for unordered maps for name qualification.
632 // static std::map<SgNode*,std::string> & get_globalQualifiedNameMapForTypes();
633 static SgUnorderedMapNodeToString & get_globalQualifiedNameMapForTypes();
634
641 // DQ (8/11/2025): Adding support for unordered maps for name qualification.
642 // static void set_globalQualifiedNameMapForTypes ( const std::map<SgNode*,std::string> & X );
643 static void set_globalQualifiedNameMapForTypes ( const SgUnorderedMapNodeToString & X );
644
645 // DQ (3/13/2019): Added name qualification support for references to types than can embed many types.
652 // DQ (8/11/2025): Adding support for unordered maps for name qualification.
653 // static std::map<SgNode*,std::map<SgNode*,std::string> > & get_globalQualifiedNameMapForMapsOfTypes();
654 static std::map<SgNode*,SgUnorderedMapNodeToString> & get_globalQualifiedNameMapForMapsOfTypes();
655
656 // DQ (3/13/2019): Added name qualification support for references to types than can embed many types.
663 // DQ (8/11/2025): Adding support for unordered maps for name qualification.
664 // static void set_globalQualifiedNameMapForMapsOfTypes ( const std::map<SgNode*,std::map<SgNode*,std::string> > & X );
665 static void set_globalQualifiedNameMapForMapsOfTypes ( const std::map<SgNode*,SgUnorderedMapNodeToString> & X );
666
676 // DQ (8/11/2025): Adding support for unordered maps for name qualification.
677 // static std::map<SgNode*,std::string> & get_globalQualifiedNameMapForTemplateHeaders();
678 static SgUnorderedMapNodeToString & get_globalQualifiedNameMapForTemplateHeaders();
679
684 // static void set_globalQualifiedNameMapForTemplateHeaders ( const std::map<SgNode*,std::string> & X );
685 static void set_globalQualifiedNameMapForTemplateHeaders ( const SgUnorderedMapNodeToString & X );
686
693 static SgUnorderedMapNodeToString& get_globalTypeNameMap();
694
700 static void set_globalTypeNameMap ( const SgUnorderedMapNodeToString& X );
701
702 /* name Persistant Attribute Mechanism
703
704 This is the persistant attribute mechanism for attaching attributed to IR nodes across
705 multiple passes. Note that these attributes are persistant in that they are preserved
706 if the AST is written out to a file and read in from a file. However, virtual function
707 in the user-defined class derived from the AstAttribute must be defined for the attribute
708 to be defined across the boundary of File I/O (simple pack and unpack functions). More
709 sophisticated mechanisms are available within the AstAttributeMechanism object
710 (e.g iterating though attributes, etc; get_attributeMechanism() is available if direct
711 access is required, however mostly only internal tools use this lower level support).
712
713 \internal This used to be a public data member, but has been changed to be a protected
714 pointer instead. The functional interface of the AstAttributeMechanism is presevered
715 but some of the names and the syntax for calling the interface have changed. The
716 pointer to the AstAttributeMechanism is now generated by ROSETTA.
717 */
718 /* */
720 virtual void addNewAttribute(std::string s,AstAttribute* a);
722 virtual AstAttribute* getAttribute(std::string s) const;
724 virtual void updateAttribute(std::string s,AstAttribute* a); // formerly called: replace in AstAttributeMechanism
729 virtual void setAttribute(std::string s,AstAttribute* a);
731 virtual void removeAttribute(std::string s);
733 virtual bool attributeExists(std::string s) const;
735 virtual int numberOfAttributes() const;
736
744 virtual AstAttributeMechanism* get_attributeMechanism() const;
751 virtual void set_attributeMechanism(AstAttributeMechanism* a);
752
753#if ALT_FIXUP_COPY
754 /* name AST Copy Support Functions
755
756 Support for IR node specific fixup of copy operation.
757 This function helps reset scopes and build untraversed parts of the
758 AST that are difficult to have be constructed using the automatically
759 generated copy functions.
760
761 \implementation These functions are used internally inside the AST copy mechanism.
762 The public interface for this functionality is given below this section.
763 */
764 virtual void fixupCopy_scopes (SgNode* copy, SgCopyHelp & help) const;
765 virtual void fixupCopy_symbols (SgNode* copy, SgCopyHelp & help) const;
766 virtual void fixupCopy_references (SgNode* copy, SgCopyHelp & help) const;
767#else
768 virtual void fixupCopy(SgNode* copy, SgCopyHelp & help) const;
769#endif
770
771 /* name Source Position Information
772 \brief Support for source code position information of all IR nodes.
773
774 These are the virtual function definitions, they are overloaded for SgLocatedNode
775 and a few of the SgSupport IR nodes.
776 */
777
786 virtual Sg_File_Info* get_file_info(void) const { return nullptr; }
787
791 virtual Sg_File_Info* get_startOfConstruct(void) const {return nullptr;}
792
796 virtual Sg_File_Info* get_endOfConstruct(void) const { return nullptr; }
797
798 /* name Control flow graph public functions
799
800 These functions return control flow graph nodes for various positions
801 around a construct. */
802 /* */
803
804#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
809#endif
810
811#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
812 /* name Control flow graph view helper functions
813
814 These functions are used internally inside the control flow graph
815 view code. The public interface for this functionality is given
816 below this section. */
817 /* */
818
820 virtual unsigned int cfgIndexForEnd() const;
821
824 virtual bool cfgIsIndexInteresting(unsigned int index) const;
825
827 virtual unsigned int cfgFindChildIndex(SgNode* n);
828
830 virtual unsigned int cfgFindNextChildIndex(SgNode* n);
831
833 virtual std::vector<VirtualCFG::CFGEdge> cfgOutEdges(unsigned int index = false);
834
836 virtual std::vector<VirtualCFG::CFGEdge> cfgInEdges(unsigned int index = false);
837#endif
838
842 static void set_globalFunctionTypeTable(SgFunctionTypeTable* globalFunctionTypeTable);
843
847 static void set_globalTypeTable(SgTypeTable* globalTypeTable);
848
849 protected:
850 static std::vector<std::tuple<unsigned char*, unsigned, VariantT>> all_pools;
851 public:
852 static VariantT variantFromPool(SgNode const * n);
853
854 /* \brief Mangled name cache for improved performance of mangled name generation
855 This mangle name caching is implemented to support better performance.
856 */
857
865
874
875 protected:
876
884
885 private:
886 // Make the copy constructor private (to avoid it being used)
887 /* We have to make the copy constructor available so that the SgUnparse_Info
888 copy constructor can access it, I'm not clear if this is a good idea.
889 */
890 // SgNode(const SgNode &); /* private so it can't be used. */
891
893 SgNode & operator= (const SgNode &) = delete;
894
895public:
909 template<class T>
910 static typename std::enable_if<std::is_base_of<SgNode, T>::value, T*>::type
912 auto node = new T;
913 node->set_parent(parent);
914 return node;
915 }
916
926 template<class T>
927 T* initParentPointer(T *child, SgNode *parent) {
928 ASSERT_not_null(parent);
929 if (child) {
930#ifndef NDEBUG
931 auto toString = [](SgNode *node) {
932 if (node) {
933 return (boost::format("(%s*)%p") % node->class_name() % node).str();
934 } else {
935 return std::string("nullptr");
936 }
937 };
938
939 ASSERT_require2(child->get_parent() == nullptr,
940 "child " + toString(child) +
941 " cannot be inserted into " + toString(parent) +
942 " because it is already a child of " + toString(child->get_parent()));
943#endif
944 child->set_parent(this);
945 }
946 return child;
947 }
948
985 template<class T>
986 typename std::enable_if<
987 std::is_pointer<T>::value,
988 void>::type
989 changeChildPointer(T& edge, T const& child) {
990#ifndef NDEBUG
991 auto toString = [](SgNode *node) {
992 if (node) {
993 return (boost::format("(%s*)%p") % node->class_name() % node).str();
994 } else {
995 return std::string("nullptr");
996 }
997 };
998#endif
999
1000 if (child != edge) {
1001 // If there is an old child, check that it has the correct parent and then remove it.
1002 if (edge) {
1003 ASSERT_require2(edge->get_parent() == this,
1004 "node " + toString(edge) +
1005 " is a child of " + toString(this) +
1006 " but has wrong parent " + toString(edge->get_parent()));
1007 edge->set_parent(nullptr);
1008 edge = nullptr;
1009 }
1010
1011 // If there is a new child, check its parent pointer and then insert it.
1012 if (child) {
1013 ASSERT_require2(child->get_parent() == nullptr,
1014 "node " + toString(child) +
1015 " is to be a child of " + toString(this) +
1016 " but is already a child of " + toString(child->get_parent()));
1017 child->set_parent(this);
1018 edge = child;
1019 }
1020 }
1021 }
1022
1023 // This gets called for non-pointers, which is the situation for nodes that are only lists of other nodes. We're currently
1024 // not checking them because the ROSETTA-generated API has too many ways to get around this check, most of which make it
1025 // impossible to enforce constraints regarding the parent/child consistency. For example:
1026 //
1027 // node->children().clear(); // removes a whole bunch of children but doesn't clear their parent pointers
1028 // node->children()[i] = child; // changes the ith child, but doesn't clear the previous ith child's parent pointer
1029 // for (auto &tmp: node->children()) tmp = nullptr; // changes each child but doesn't clear parent pointers
1030 // ad nausiam...
1031 template<class T>
1032 typename std::enable_if<
1033 !std::is_pointer<T>::value,
1034 void>::type
1035 changeChildPointer(T& edge, T const& child) {
1036 edge = child;
1037 }
1041private:
1042 // This is called by the debugSerializationBegin and debugSerializationEnd that are in turn called at the beginning and end of
1043 // each AST node's serialization function. The implementation below uses two counters: classSerializationDepth shared by all
1044 // instances of this class, and objectSerializationDepth_ which is a per-instance counter. The relationship of these two
1045 // counters can tell us how deeply nested these recursive calls are, and which of those recursion levels are due to traversing
1046 // through the base classes versus traversing through data members. In the output, we use one character of indentation per
1047 // recursion level, with spaces (' ') representing recursion due to data members and dots ('.') representing recursion due to
1048 // base classes.
1049 void debugSerializationHelper(const char*, bool) {}
1050
1051protected:
1081 virtual void destructorHelper() {}
1082
1083protected:
1091 virtual void debugSerializationBegin(const char *className) {
1092 debugSerializationHelper(className, true);
1093 }
1094 virtual void debugSerializationEnd(const char *className) {
1095 debugSerializationHelper(className, false);
1096 }
1099 public:
1100
1101
1102
1103// End of memberFunctionString
1104
1105
1106
1107
1108 public:
1109 SgNode* get_freepointer() const;
1110 void set_freepointer(SgNode* freepointer);
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122 public:
1123 virtual ~SgNode();
1124
1125
1126 public:
1127 SgNode();
1128
1129 protected:
1130// Start of memberFunctionString
1131SgNode* p_parent;
1132
1133// End of memberFunctionString
1134// Start of memberFunctionString
1135bool p_isModified;
1136
1137// End of memberFunctionString
1138// Start of memberFunctionString
1139bool p_containsTransformation;
1140
1141// End of memberFunctionString
1142// Start of memberFunctionString
1143SgNode* p_freepointer;
1144
1145// End of memberFunctionString
1146// Start of memberFunctionString
1147static SgFunctionTypeTable* p_globalFunctionTypeTable;
1148
1149// End of memberFunctionString
1150// Start of memberFunctionString
1151static SgTypeTable* p_globalTypeTable;
1152
1153// End of memberFunctionString
1154// Start of memberFunctionString
1155static std::map<SgNode*,std::string> p_globalMangledNameMap;
1156
1157// End of memberFunctionString
1158// Start of memberFunctionString
1159static std::map<std::string, uint64_t> p_shortMangledNameCache;
1160
1161// End of memberFunctionString
1162// Start of memberFunctionString
1163static std::unordered_map<SgNode*,std::string> p_globalQualifiedNameMapForNames;
1164
1165// End of memberFunctionString
1166// Start of memberFunctionString
1167static std::unordered_map<SgNode*,std::string> p_globalQualifiedNameMapForTypes;
1168
1169// End of memberFunctionString
1170// Start of memberFunctionString
1171static std::unordered_map<SgNode*,std::string> p_globalQualifiedNameMapForTemplateHeaders;
1172
1173// End of memberFunctionString
1174// Start of memberFunctionString
1175static std::unordered_map<SgNode*,std::string> p_globalTypeNameMap;
1176
1177// End of memberFunctionString
1178// Start of memberFunctionString
1179static std::map<SgNode*,std::unordered_map<SgNode*,std::string> > p_globalQualifiedNameMapForMapsOfTypes;
1180
1181// End of memberFunctionString
1182
1186 friend struct Rose::Traits::generated::describe_field_t<SgNode, bool,&SgNode::p_containsTransformation>;
1188
1189/* #line 21 "/workspace/src/ROSETTA/Grammar/grammarClassDeclarationMacros.macro" */
1190
1191
1192 };
1193#endif
1194
1195// postdeclarations for SgNode
1196
1197/* #line 1198 "../../../src/frontend/SageIII//SgNode.h" */
1198
1199/* #line 27 "/workspace/src/ROSETTA/Grammar/grammarClassDeclarationMacros.macro after subst for $POSTDECLARATIONS" */
1200
1201/* #line 28 "/workspace/src/ROSETTA/Grammar/grammarClassDeclarationMacros.macro" */
1202
1203
1204/* #line 1205 "../../../src/frontend/SageIII//SgNode.h" */
1205
1206#endif // ROSE_SgNode_H
1207
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:791
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:796
virtual size_t get_numberOfTraversalSuccessors() const
return number of children in the traversal successor list
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< std::string > get_traversalSuccessorNamesContainer() const
container of names of variables or container indices used used in the traversal to access AST success...
virtual void debugSerializationEnd(const char *className)
Called by generated serializers.
Definition SgNode.h:1094
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:989
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
virtual size_t get_childIndex(SgNode *child) const
index-based access to traversal successors by child node
SgNode * get_parent() const
Access function for parent node.
virtual std::vector< SgNode * > get_traversalSuccessorContainer() const
container of pointers to AST successor nodes used in the traversal overridden in every class by gener...
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 void debugSerializationBegin(const char *className)
Called by generated serializers.
Definition SgNode.h:1091
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:911
virtual SgNode * get_traversalSuccessorByIndex(size_t idx) const
index-based access to traversal successors by index number
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:786
virtual std::vector< VirtualCFG::CFGEdge > cfgOutEdges(unsigned int index=false)
Find the out edges of a CFG node – internal version.
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:1035
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:927
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:1081
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.