5#include <Cxx_GrammarDeclarations.h> 
   27#include <ROSE_DEPRECATED.h> 
   29#include <rosePublicConfig.h> 
   31#include <sageContainer.h> 
   32#include <boost/format.hpp> 
   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> 
   43#include <Sawyer/CommandLine.h> 
   44#include <Sawyer/Interval.h> 
   45#include <Sawyer/IntervalSet.h> 
   47#include "processSupport.h" 
   48#define __builtin_constant_p(exp) (0) 
   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>                                 
   56#include <Rose/BinaryAnalysis/RegisterDescriptor.h> 
   57#include <Rose/BinaryAnalysis/InstructionMap.h> 
   58#include <ROSE_NELMTS.h> 
   61#include <Rose/Constants.h> 
   63#include <sageTraversal.h> 
   66#include <sageMemory.h> 
   67#include <Cxx_GrammarVariants.h> 
   68#include <Cxx_GrammarStorageClasses.h> 
   69#include <virtualCFG.h> 
   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; } } }
 
   74#ifdef ROSE_ENABLE_BINARY_ANALYSIS 
   87class UnparseFormatHelp;
 
   90class AstSpecificDataManagingClassStorageClass;
 
  131          enum { static_variant = V_SgNode };
 
  146          static const unsigned pool_size; 
 
  148          static std::vector<unsigned char *> pools; 
 
  150          static SgNode * next_node; 
 
  153          static unsigned long initializeStorageClassArray(SgNodeStorageClass *); 
 
  156          static void clearMemoryPool(); 
 
  157          static void deleteMemoryPool(); 
 
  160          static void extendMemoryPoolForFileIO(); 
 
  163          static SgNode * getPointerFromGlobalIndex(
unsigned long); 
 
  165          static SgNode * getPointerFromGlobalIndex(AstSpecificDataManagingClass *, 
unsigned long); 
 
  168          static unsigned long getNumberOfValidNodesAndSetGlobalIndexInFreepointer(
unsigned long); 
 
  170          static void resetValidFreepointers(); 
 
  172          static unsigned long getNumberOfLastValidPointer(); 
 
  175#if defined(INLINE_FUNCTIONS) 
  177          inline void *
operator new (
size_t size);
 
  180          void *
operator new (
size_t size);
 
  183          void operator delete (
void* pointer, 
size_t size);
 
  186          void operator delete (
void* pointer)
 
  189               SgNode::operator 
delete (pointer,
sizeof(
SgNode));
 
  232#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT 
  255          virtual int variant() const ROSE_DEPRECATED_FUNCTION;
 
  310        static std::string getNodeIdStringInternal(
SgNode* sgnode);
 
  437          friend class SgNodeStorageClass;
 
  440          friend class AstSpecificDataManagingClass;
 
  443          friend class AstSpecificDataManagingClassStorageClass;
 
  446          SgNode( 
const SgNodeStorageClass& source );
 
  475#define BUILD_ATERM_SUPPORT 0 
  476   #if BUILD_ATERM_SUPPORT 
  477   #ifdef ROSE_USE_ROSE_ATERM_SUPPORT 
  489          virtual ATerm generate_ATerm();
 
  492          virtual void generate_ATerm_Annotation(ATerm & term);
 
  553           std::string unparseToString() 
const;
 
  570          int variant() const ROSE_DEPRECATED_FUNCTION {
return (
int)this->variantT();}
 
  573          static std::vector<VariantT> getClassHierarchySubTreeFunction( VariantT v);
 
  574          static void getClassHierarchySubTreeFunction( VariantT v, std::vector<VariantT>&);
 
  587          void set_isVisited ( 
bool isVisited ) ROSE_DEPRECATED_FUNCTION;
 
  593          static std::map<
SgNode*,std::
string> & get_globalMangledNameMap();
 
  597          static 
void clearGlobalMangledNameMap();
 
  604          static std::map<std::
string, uint64_t> & get_shortMangledNameCache();
 
  614          static SgUnorderedMapNodeToString & get_globalQualifiedNameMapForNames();
 
  623          static 
void set_globalQualifiedNameMapForNames ( const SgUnorderedMapNodeToString & X );
 
  633          static SgUnorderedMapNodeToString & get_globalQualifiedNameMapForTypes();
 
  643          static 
void set_globalQualifiedNameMapForTypes ( const SgUnorderedMapNodeToString & X );
 
  654          static std::map<
SgNode*,SgUnorderedMapNodeToString> & get_globalQualifiedNameMapForMapsOfTypes();
 
  665          static 
void set_globalQualifiedNameMapForMapsOfTypes ( const std::map<
SgNode*,SgUnorderedMapNodeToString> & X );
 
  678          static SgUnorderedMapNodeToString & get_globalQualifiedNameMapForTemplateHeaders();
 
  685          static 
void set_globalQualifiedNameMapForTemplateHeaders ( const SgUnorderedMapNodeToString & X );
 
  693          static SgUnorderedMapNodeToString& get_globalTypeNameMap();
 
  700          static 
void set_globalTypeNameMap ( const SgUnorderedMapNodeToString& X );
 
  731         virtual 
void removeAttribute(std::
string s);
 
  733         virtual 
bool attributeExists(std::
string s) const;
 
  735         virtual 
int numberOfAttributes() const;
 
  804#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT 
  811#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT 
  833          virtual std::vector<VirtualCFG::CFGEdge> 
cfgOutEdges(
unsigned int index = 
false);
 
  836          virtual std::vector<VirtualCFG::CFGEdge> 
cfgInEdges(
unsigned int index = 
false);
 
  850          static std::vector<std::tuple<unsigned char*, unsigned, VariantT>> all_pools;
 
  852          static VariantT variantFromPool(
SgNode const * n);
 
  910    static typename std::enable_if<std::is_base_of<SgNode, T>::value, T*>::type
 
  913        node->set_parent(parent);
 
 
  928        ASSERT_not_null(parent);
 
  931            auto toString = [](
SgNode *node) {
 
  933                    return (boost::format(
"(%s*)%p") % node->class_name() % node).str();
 
  935                    return std::string(
"nullptr");
 
  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()));
 
  944            child->set_parent(
this);
 
 
  986    typename std::enable_if<
 
  987        std::is_pointer<T>::value,
 
  991        auto toString = [](
SgNode *node) {
 
  993                return (boost::format(
"(%s*)%p") % node->class_name() % node).str();
 
  995                return std::string(
"nullptr");
 
 1000        if (child != 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);
 
 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);
 
 
 1032    typename std::enable_if<
 
 1033        !std::is_pointer<T>::value,
 
 1049    void debugSerializationHelper(
const char*, 
bool) {}
 
 1092        debugSerializationHelper(className, 
true);
 
 
 1095        debugSerializationHelper(className, 
false);
 
 
 1109         SgNode* get_freepointer() 
const;
 
 1110         void set_freepointer(
SgNode* freepointer);
 
 1139bool p_containsTransformation;
 
 1155static std::map<SgNode*,std::string> p_globalMangledNameMap;
 
 1159static std::map<std::string, uint64_t> p_shortMangledNameCache;
 
 1163static std::unordered_map<SgNode*,std::string> p_globalQualifiedNameMapForNames;
 
 1167static std::unordered_map<SgNode*,std::string> p_globalQualifiedNameMapForTypes;
 
 1171static std::unordered_map<SgNode*,std::string> p_globalQualifiedNameMapForTemplateHeaders;
 
 1175static std::unordered_map<SgNode*,std::string> p_globalTypeNameMap;
 
 1179static std::map<SgNode*,std::unordered_map<SgNode*,std::string> > p_globalQualifiedNameMapForMapsOfTypes;
 
Class holding static data and functions supporting File I/O.
 
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.
 
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...
 
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...
 
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.
 
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.
 
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.
 
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.
 
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...
 
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.
 
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.
 
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.
 
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.
 
void copy(const Word *src, const BitRange &srcRange, Word *dst, const BitRange &dstRange)
Copy some bits.