ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SageInterface Namespace Reference

Classes

class  DeclarationSets
 
class  UniqueNameAttribute
 A persistent attribute to represent a unique name for an expression. More...
 
struct  hash_nodeptr
 
class  OutputLocalSymbolTables
 
class  StatementGenerator
 Interface for creating a statement whose computation writes its answer into a given variable. More...
 

Typedefs

typedef bool(* EquivalenceTestFunctionType )(SgNode *x, SgNode *y)
 

Functions

DeclarationSetsbuildDeclarationSets (SgNode *)
 
SgAsmInterpretationgetMainInterpretation (SgAsmGenericFile *file)
 
uint64_t getAsmConstant (SgAsmValueExpression *e)
 Get the unsigned value of a disassembled constant. More...
 
int64_t getAsmSignedConstant (SgAsmValueExpression *e)
 Get the signed value of a disassembled constant. More...
 
void addMessageStatement (SgStatement *stmt, std::string message)
 Function to add "C" style comment to statement. More...
 
void supplementReplacementSymbolMap (rose_hash::unordered_map< SgNode *, SgNode *, hash_nodeptr > &inputReplacementMap)
 
void updateDefiningNondefiningLinks (SgFunctionDeclaration *func, SgScopeStatement *scope)
 Update defining and nondefining links due to a newly introduced function declaration. Should be used after inserting the function into a scope. More...
 
bool hasTemplateSyntax (const SgName &name)
 
std::set< unsigned int > collectSourceSequenceNumbers (SgNode *astNode)
 
bool HasNoThrowAssign (const SgType *const inputType)
 
bool HasNoThrowCopy (const SgType *const inputType)
 
bool HasNoThrowConstructor (const SgType *const inputType)
 
bool HasTrivialAssign (const SgType *const inputType)
 
bool HasTrivialCopy (const SgType *const inputType)
 
bool HasTrivialConstructor (const SgType *const inputType)
 
bool HasTrivialDestructor (const SgType *const inputType)
 
bool HasVirtualDestructor (const SgType *const inputType)
 
bool IsBaseOf (const SgType *const inputBaseType, const SgType *const inputDerivedType)
 
bool IsAbstract (const SgType *const inputType)
 
bool IsClass (const SgType *const inputType)
 
bool IsEmpty (const SgType *const inputType)
 
bool IsEnum (const SgType *const inputType)
 
bool IsPod (const SgType *const inputType)
 
bool IsPolymorphic (const SgType *const inputType)
 
bool IsStandardLayout (const SgType *const inputType)
 
bool IsLiteralType (const SgType *const inputType)
 
bool IsTrivial (const SgType *const inputType)
 
bool IsUnion (const SgType *const inputType)
 
SgTypeUnderlyingType (SgType *type)
 
void supportForInitializedNameLists (SgScopeStatement *scope, SgInitializedNamePtrList &variableList)
 
bool isStructurallyEquivalentAST (SgNode *tree1, SgNode *tree2)
 
std::string getTempDirectory (SgProject *project)
 
void destroyTempDirectory (std::string)
 
SgFileprocessFile (SgProject *, std::string, bool unparse=false)
 
std::string preprocessPackage (SgProject *, std::string)
 
std::string preprocessImport (SgProject *, std::string)
 
SgFilepreprocessCompilationUnit (SgProject *, std::string, std::string, bool unparse=true)
 
SgClassDefinitionfindJavaPackage (SgScopeStatement *, std::string)
 
SgClassDefinitionfindOrInsertJavaPackage (SgProject *, std::string, bool create_directory=false)
 
SgClassDeclarationfindOrImportJavaClass (SgProject *, SgClassDefinition *package_definition, std::string)
 
SgClassDeclarationfindOrImportJavaClass (SgProject *, std::string, std::string)
 
SgClassDeclarationfindOrImportJavaClass (SgProject *, SgClassType *)
 
SgMemberFunctionDeclarationfindJavaMain (SgClassDefinition *)
 
SgMemberFunctionDeclarationfindJavaMain (SgClassType *)
 
void addComment (SgAsmStatement *stmt, const std::string &input_string)
 
SgAsmElfSectiongetSection (SgProject *project, const std::string &name)
 
SgAsmElfSectiongetSection (SgProject *project, size_t ptr)
 
SgAsmFunctiongetAsmFunction (SgAsmInstruction *asmInstruction)
 Traverses AST backwards up the tree along the "parent" edges to the SgAsmFunction. More...
 
SgAsmBlockgetAsmBlock (SgAsmInstruction *asmInstruction)
 Traverses AST backwards up the tree along the "parent" edges to the SgAsmBlock. More...
 
SgAsmInterpretationgetAsmInterpretation (SgAsmNode *asmNode)
 Traverses AST backwards up the tree along the "parent" edges to the SgAsmInterpretation. More...
 
std::string generateUniqueName (size_t value, std::map< size_t, int > &usedOffsets, size_t &counter)
 
size_t get_value (SgAsmValueExpression *asmValueExpression)
 
std::string get_valueString (SgAsmValueExpression *asmValueExpression)
 
bool isMovInstruction (SgAsmInstruction *asmInstruction)
 
bool isInstructionKind (SgAsmInstruction *asmInstruction, X86InstructionKind instuctionKind)
 
bool equivalenceTest (SgNode *x, SgNode *y)
 
std::vector< SgNode * > flattenAST (SgNode *node)
 
std::vector< SgNode * > matchAST (SgNode *node, std::vector< SgNode * > &listOfNodes, EquivalenceTestFunctionType equivalenceTest)
 
std::vector< SgNode * > find (SgNode *astNode, SgNode *target, EquivalenceTestFunctionType equivalenceTest)
 
bool isNOP (SgAsmInstruction *asmInstruction)
 Test an instruction for if it has no side-effect to the state (is so then it is a NOP). This is a more general test than if it is equivelent to the NOP memonic instruction. More...
 
bool isNOP (const std::vector< SgAsmInstruction * > &asmInstructionList)
 Test a sequence of instructions for it they (as a set) have no side-effects to the state (is so then it is a NOP sequence). More...
 
std::vector< std::vector
< SgAsmInstruction * > > 
find_NOP_sequences (SgAsmBlock *asmBlock)
 find sequences of NOP instructions in a SgAsmBlock More...
 
void insertInstruction (SgAsmInstruction *targetInstruction, SgAsmInstruction *newInstruction, bool insertBefore)
 Support for insertion of instruction relative to a target instruction. More...
 
void insertInstructionBefore (SgAsmInstruction *targetInstruction, SgAsmInstruction *newInstruction)
 Insert a instruction before a target instruction. More...
 
void removeInstruction (SgAsmStatement *instruction)
 Remove a instruction. More...
 
Symbol tables

utility functions for symbol tables

ROSE_DLL_API SgVariableSymbollookupVariableSymbolInParentScopes (const SgName &name, SgScopeStatement *currentScope=NULL)
 Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeStack if currentscope is not given or NULL. More...
 
ROSE_DLL_API SgSymbollookupSymbolInParentScopes (const SgName &name, SgScopeStatement *currentScope=NULL, SgTemplateParameterPtrList *templateParameterList=NULL, SgTemplateArgumentPtrList *templateArgumentList=NULL)
 Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeStack if currentscope is not given or NULL. More...
 
ROSE_DLL_API SgFunctionSymbollookupFunctionSymbolInParentScopes (const SgName &functionName, SgScopeStatement *currentScope=NULL)
 look up the first matched function symbol in parent scopes given only a function name, starting from top of ScopeStack if currentscope is not given or NULL More...
 
ROSE_DLL_API SgFunctionSymbollookupFunctionSymbolInParentScopes (const SgName &functionName, const SgType *t, SgScopeStatement *currentScope=NULL)
 look up function symbol in parent scopes given both name and function type, starting from top of ScopeStack if currentscope is not given or NULL More...
 
ROSE_DLL_API SgClassSymbollookupClassSymbolInParentScopes (const SgName &name, SgScopeStatement *currentScope=NULL, SgTemplateArgumentPtrList *templateArgumentList=NULL)
 Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeStack if currentscope is not given or NULL. More...
 
ROSE_DLL_API SgTypedefSymbollookupTypedefSymbolInParentScopes (const SgName &name, SgScopeStatement *currentScope=NULL)
 Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeStack if currentscope is not given or NULL. More...
 
ROSE_DLL_API
SgTemplateClassSymbol
lookupTemplateClassSymbolInParentScopes (const SgName &name, SgTemplateParameterPtrList *templateParameterList, SgTemplateArgumentPtrList *templateArgumentList, SgScopeStatement *cscope=NULL)
 Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeStack if currentscope is not given or NULL. More...
 
ROSE_DLL_API SgEnumSymbollookupEnumSymbolInParentScopes (const SgName &name, SgScopeStatement *currentScope=NULL)
 Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeStack if currentscope is not given or NULL. More...
 
ROSE_DLL_API SgNamespaceSymbollookupNamespaceSymbolInParentScopes (const SgName &name, SgScopeStatement *currentScope=NULL)
 Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeStack if currentscope is not given or NULL. More...
 
ROSE_DLL_API int set_name (SgInitializedName *initializedNameNode, SgName new_name)
 set_name of symbol in symbol table. More...
 
void outputGlobalFunctionTypeSymbolTable ()
 Output function type symbols in global function type symbol table. More...
 
ROSE_DLL_API void outputLocalSymbolTables (SgNode *node)
 Output the local symbol tables. More...
 
void rebuildSymbolTable (SgScopeStatement *scope)
 Regenerate the symbol table. More...
 
void clearUnusedVariableSymbols (SgNode *root=NULL)
 Clear those variable symbols with unknown type (together with initialized names) which are also not referenced by any variable references or declarations under root. If root is NULL, all symbols with unknown type will be deleted. More...
 
void fixupReferencesToSymbols (const SgScopeStatement *this_scope, SgScopeStatement *copy_scope, SgCopyHelp &help)
 All the symbol table references in the copied AST need to be reset after rebuilding the copied scope's symbol table. More...
 
Stringify

Generate a useful string (name) to describe a SgNode

std::string get_name (const SgNode *node)
 Generate a useful name to describe the SgNode. More...
 
std::string get_name (const SgStatement *stmt)
 Generate a useful name to describe the declaration. More...
 
std::string get_name (const SgExpression *expr)
 Generate a useful name to describe the expression. More...
 
std::string get_name (const SgDeclarationStatement *declaration)
 Generate a useful name to describe the declaration. More...
 
std::string get_name (const SgScopeStatement *scope)
 Generate a useful name to describe the scope. More...
 
std::string get_name (const SgSymbol *symbol)
 Generate a useful name to describe the SgSymbol. More...
 
std::string get_name (const SgType *type)
 Generate a useful name to describe the SgType. More...
 
std::string get_name (const SgSupport *node)
 Generate a useful name to describe the SgSupport IR node. More...
 
std::string get_name (const SgLocatedNodeSupport *node)
 Generate a useful name to describe the SgLocatedNodeSupport IR node. More...
 
std::string get_name (const SgC_PreprocessorDirectiveStatement *directive)
 Generate a useful name to describe the SgC_PreprocessorDirectiveStatement IR node. More...
 
std::string get_name (const SgToken *token)
 Generate a useful name to describe the SgToken IR node. More...
 
Class utilities
SgMemberFunctionDeclarationgetDefaultDestructor (SgClassDeclaration *classDeclaration)
 Get the default destructor from the class declaration. More...
 
ROSE_DLL_API
SgMemberFunctionDeclaration
getDefaultConstructor (SgClassDeclaration *classDeclaration)
 Get the default constructor from the class declaration. More...
 
bool templateDefinitionIsInClass (SgTemplateInstantiationMemberFunctionDecl *memberFunctionDeclaration)
 Return true if template definition is in the class, false if outside of class. More...
 
SgTemplateInstantiationMemberFunctionDeclbuildForwardFunctionDeclaration (SgTemplateInstantiationMemberFunctionDecl *memberFunctionInstantiation)
 Generate a non-defining (forward) declaration from a defining function declaration. More...
 
bool isStructDeclaration (SgNode *node)
 Check if a SgNode is a declaration for a structure. More...
 
bool isUnionDeclaration (SgNode *node)
 Check if a SgNode is a declaration for a union. More...
 
Misc.

Not sure the classifications right now

void whereAmI (SgNode *node)
 Diagnostic function for tracing back through the parent list to understand at runtime where in the AST a failure happened. More...
 
std::string extractPragmaKeyword (const SgPragmaDeclaration *)
 Extract a SgPragmaDeclaration's leading keyword . For example "#pragma omp parallel" has a keyword of "omp". More...
 
ROSE_DLL_API bool isOmpStatement (SgNode *)
 Check if a node is SgOmp*Statement. More...
 
bool isOverloaded (SgFunctionDeclaration *functionDeclaration)
 Return true if function is overloaded. More...
 
void initializeIfStmt (SgIfStmt *ifstmt, SgStatement *conditional, SgStatement *true_body, SgStatement *false_body)
 Support function used for variable declarations in conditionals. More...
 
void initializeSwitchStatement (SgSwitchStatement *switchStatement, SgStatement *item_selector, SgStatement *body)
 Support function used for variable declarations in conditionals. More...
 
void initializeWhileStatement (SgWhileStmt *whileStatement, SgStatement *condition, SgStatement *body, SgStatement *else_body)
 Support function used for variable declarations in conditionals. More...
 
void annotateExpressionsWithUniqueNames (SgProject *project)
 Generate unique names for expressions and attach the names as persistent attributes ("UniqueNameAttribute") More...
 
ROSE_DLL_API bool isMain (const SgNode *node)
 Check if a SgNode is a main() function declaration. More...
 
std::string generateUniqueName (const SgNode *node, bool ignoreDifferenceBetweenDefiningAndNondefiningDeclarations)
 Generate unique name from C and C++ constructs. The name may contain space. More...
 
std::string generateUniqueVariableName (SgScopeStatement *scope, std::string baseName="temp")
 Generate a name that is unique in the current scope and any parent and children scopes. More...
 
std::string declarationPositionString (const SgDeclarationStatement *declaration)
 Generate a unique string from the source file position information. More...
 
ROSE_DLL_API std::string generateProjectName (const SgProject *project, bool supressSuffix=false)
 Added mechanism to generate project name from list of file names. More...
 
SgFunctionDeclarationgetDeclarationOfNamedFunction (SgExpression *func)
 Given a SgExpression that represents a named function (or bound member function), return the mentioned function. More...
 
SgExpressionforallMaskExpression (SgForAllStatement *stmt)
 Get the mask expression from the header of a SgForAllStatement. More...
 
void addVarRefExpFromArrayDimInfo (SgNode *astNode, Rose_STL_Container< SgNode * > &NodeList_t)
 Find all SgPntrArrRefExp under astNode, then add SgVarRefExp (if any) of SgPntrArrRefExp's dim_info into NodeList_t. More...
 
void clearMangledNameCache (SgGlobal *globalScope)
 Support for faster mangled name generation (caching avoids recomputation). More...
 
void resetMangledNameCache (SgGlobal *globalScope)
 Diagnostic function for tracing back through the parent list to understand at runtime where in the AST a failure happened. More...
 
std::string getMangledNameFromCache (SgNode *astNode)
 Diagnostic function for tracing back through the parent list to understand at runtime where in the AST a failure happened. More...
 
std::string addMangledNameToCache (SgNode *astNode, const std::string &mangledName)
 Diagnostic function for tracing back through the parent list to understand at runtime where in the AST a failure happened. More...
 
SgDeclarationStatementgetNonInstantiatonDeclarationForClass (SgTemplateInstantiationMemberFunctionDecl *memberFunctionInstantiation)
 Diagnostic function for tracing back through the parent list to understand at runtime where in the AST a failure happened. More...
 
void setBaseTypeDefiningDeclaration (SgVariableDeclaration *var_decl, SgDeclarationStatement *base_decl)
 a better version for SgVariableDeclaration::set_baseTypeDefininingDeclaration(), handling all side effects automatically Used to have a struct declaration embedded into a variable declaration More...
 
bool declarationPreceedsDefinition (SgDeclarationStatement *nonDefiningDeclaration, SgDeclarationStatement *definingDeclaration)
 Check if a defining declaration comes before of after the non-defining declaration. More...
 
bool functionCallExpressionPreceedsDeclarationWhichAssociatesScope (SgFunctionCallExp *functionCall)
 Diagnostic function for tracing back through the parent list to understand at runtime where in the AST a failure happened. More...
 
ROSE_DLL_API std::vector
< SgNode * > 
astIntersection (SgNode *original, SgNode *copy, SgCopyHelp *help=NULL)
 Compute the intersection set for two ASTs. More...
 
ROSE_DLL_API SgNodedeepCopyNode (const SgNode *subtree)
 Deep copy an arbitrary subtree. More...
 
template<typename NodeType >
NodeType * deepCopy (const NodeType *subtree)
 A template function for deep copying a subtree. It is also used to create deepcopy functions with specialized parameter and return types. e.g SgExpression* copyExpression(SgExpression* e);. More...
 
ROSE_DLL_API SgExpressioncopyExpression (SgExpression *e)
 Deep copy an expression. More...
 
ROSE_DLL_API SgStatementcopyStatement (SgStatement *s)
 Deep copy a statement. More...
 
ROSE_DLL_API SgVariableSymbolgetFirstVarSym (SgVariableDeclaration *decl)
 Get the variable symbol for the first initialized name of a declaration stmt. More...
 
ROSE_DLL_API SgInitializedNamegetFirstInitializedName (SgVariableDeclaration *decl)
 Get the first initialized name of a declaration statement. More...
 
ROSE_DLL_API void myRemoveStatement (SgStatement *stmt)
 A special purpose statement removal function, originally from inlinerSupport.h, Need Jeremiah's attention to refine it. Please don't use it for now. More...
 
ROSE_DLL_API bool isConstantTrue (SgExpression *e)
 Diagnostic function for tracing back through the parent list to understand at runtime where in the AST a failure happened. More...
 
ROSE_DLL_API bool isConstantFalse (SgExpression *e)
 Diagnostic function for tracing back through the parent list to understand at runtime where in the AST a failure happened. More...
 
ROSE_DLL_API bool isCallToParticularFunction (SgFunctionDeclaration *decl, SgExpression *e)
 Diagnostic function for tracing back through the parent list to understand at runtime where in the AST a failure happened. More...
 
ROSE_DLL_API bool isCallToParticularFunction (const std::string &qualifiedName, size_t arity, SgExpression *e)
 Diagnostic function for tracing back through the parent list to understand at runtime where in the AST a failure happened. More...
 
bool ROSE_DLL_API isStatic (SgDeclarationStatement *stmt)
 Check if a declaration has a "static' modifier. More...
 
ROSE_DLL_API void setStatic (SgDeclarationStatement *stmt)
 Set a declaration as static. More...
 
ROSE_DLL_API bool isExtern (SgDeclarationStatement *stmt)
 Check if a declaration has an "extern" modifier. More...
 
ROSE_DLL_API void setExtern (SgDeclarationStatement *stmt)
 Set a declaration as extern. More...
 
bool isAssignmentStatement (SgNode *_s, SgExpression **lhs=NULL, SgExpression **rhs=NULL, bool *readlhs=NULL)
 Check if a SgNode _s is an assignment statement (any of =,+=,-=,&=,/=, ^=, etc) More...
 
ROSE_DLL_API SgInitializedNameconvertRefToInitializedName (SgNode *current)
 Variable references can be introduced by SgVarRef, SgPntrArrRefExp, SgInitializedName, SgMemberFunctionRef etc. This function will convert them all to a top level SgInitializedName. More...
 
ROSE_DLL_API
AbstractHandle::abstract_handle * 
buildAbstractHandle (SgNode *)
 Build an abstract handle from an AST node, reuse previously built handle when possible. More...
 
ROSE_DLL_API SgNodegetSgNodeFromAbstractHandleString (const std::string &input_string)
 Obtain a matching SgNode from an abstract handle string. More...
 
ROSE_DLL_API void dumpInfo (SgNode *node, std::string desc="")
 Dump information about a SgNode for debugging. More...
 
ROSE_DLL_API std::vector
< SgDeclarationStatement * > 
sortSgNodeListBasedOnAppearanceOrderInSource (const std::vector< SgDeclarationStatement * > &nodevec)
 Reorder a list of declaration statements based on their appearance order in source files. More...
 
bool isPrefixOperator (SgExpression *exp)
 Is an overloaded operator a prefix operator (e.g. address operator X * operator&(), dereference operator X & operator*(), unary plus operator X & operator+(), etc. More...
 
bool isPrefixOperatorName (const SgName &functionName)
 Check for proper names of possible prefix operators (used in isPrefixOperator()). More...
 
bool isPostfixOperator (SgExpression *exp)
 Is an overloaded operator a postfix operator. (e.g. ). More...
 
bool isIndexOperator (SgExpression *exp)
 Is an overloaded operator an index operator (also referred to as call or subscript operators). (e.g. X & operator()() or X & operator[]()). More...
 
AST properties

version, language properties of current AST.

ROSE_DLL_API bool is_C_language ()
 
ROSE_DLL_API bool is_OpenMP_language ()
 
ROSE_DLL_API bool is_UPC_language ()
 
ROSE_DLL_API bool is_UPC_dynamic_threads ()
 Check if dynamic threads compilation is used for UPC programs. More...
 
ROSE_DLL_API bool is_C99_language ()
 
ROSE_DLL_API bool is_Cxx_language ()
 
ROSE_DLL_API bool is_Java_language ()
 
ROSE_DLL_API bool is_Fortran_language ()
 
ROSE_DLL_API bool is_CAF_language ()
 
ROSE_DLL_API bool is_PHP_language ()
 
ROSE_DLL_API bool is_Python_language ()
 
ROSE_DLL_API bool is_Cuda_language ()
 
ROSE_DLL_API bool is_X10_language ()
 
ROSE_DLL_API bool is_binary_executable ()
 
ROSE_DLL_API bool is_mixed_C_and_Cxx_language ()
 
ROSE_DLL_API bool is_mixed_Fortran_and_C_language ()
 
ROSE_DLL_API bool is_mixed_Fortran_and_Cxx_language ()
 
ROSE_DLL_API bool is_mixed_Fortran_and_C_and_Cxx_language ()
 
Scope
void resetScopeNumbers (SgFunctionDefinition *functionDeclaration)
 Assigns unique numbers to each SgScopeStatement of a function. More...
 
void clearScopeNumbers (SgFunctionDefinition *functionDefinition)
 Clears the cache of scope,integer pairs for the input function. More...
 
SgNamespaceDefinitionStatementenclosingNamespaceScope (SgDeclarationStatement *declaration)
 Find the enclosing namespace of a declaration. More...
 
bool isPrototypeInScope (SgScopeStatement *scope, SgFunctionDeclaration *functionDeclaration, SgDeclarationStatement *startingAtDeclaration)
 Assigns unique numbers to each SgScopeStatement of a function. More...
 
bool ROSE_DLL_API isAncestor (SgNode *node1, SgNode *node2)
 check if node1 is a strict ancestor of node 2. (a node is not considered its own ancestor) More...
 
Preprocessing Information

#if-#else-#end, comments, #include, etc

void dumpPreprocInfo (SgLocatedNode *locatedNode)
 Dumps a located node's preprocessing information. More...
 
ROSE_DLL_API PreprocessingInfoinsertHeader (const std::string &filename, PreprocessingInfo::RelativePositionType position=PreprocessingInfo::after, bool isSystemHeader=false, SgScopeStatement *scope=NULL)
 Insert #include "filename" or #include <filename> (system header) into the global scope containing the current scope, right after other #include XXX. More...
 
ROSE_DLL_API void moveUpPreprocessingInfo (SgStatement *stmt_dst, SgStatement *stmt_src, PreprocessingInfo::RelativePositionType src_position=PreprocessingInfo::undef, PreprocessingInfo::RelativePositionType dst_position=PreprocessingInfo::undef, bool usePrepend=false)
 Identical to movePreprocessingInfo(), except for the stale name and confusing order of parameters. It will be deprecated soon. More...
 
ROSE_DLL_API void movePreprocessingInfo (SgStatement *stmt_src, SgStatement *stmt_dst, PreprocessingInfo::RelativePositionType src_position=PreprocessingInfo::undef, PreprocessingInfo::RelativePositionType dst_position=PreprocessingInfo::undef, bool usePrepend=false)
 Move preprocessing information of stmt_src to stmt_dst, Only move preprocessing information from the specified source-relative position to a specified target position, otherwise move all preprocessing information with position information intact. The preprocessing information is appended to the existing preprocessing information list of the target node by default. Prepending is used if usePreprend is set to true. Optionally, the relative position can be adjust after the moving using dst_position. More...
 
ROSE_DLL_API void cutPreprocessingInfo (SgLocatedNode *src_node, PreprocessingInfo::RelativePositionType pos, AttachedPreprocessingInfoType &save_buf)
 Cut preprocessing information from a source node and save it into a buffer. Used in combination of pastePreprocessingInfo(). The cut-paste operation is similar to moveUpPreprocessingInfo() but it is more flexible in that the destination node can be unknown during the cut operation. More...
 
ROSE_DLL_API void pastePreprocessingInfo (SgLocatedNode *dst_node, PreprocessingInfo::RelativePositionType pos, AttachedPreprocessingInfoType &saved_buf)
 Paste preprocessing information from a buffer to a destination node. Used in combination of cutPreprocessingInfo() More...
 
ROSE_DLL_API PreprocessingInfoattachArbitraryText (SgLocatedNode *target, const std::string &text, PreprocessingInfo::RelativePositionType position=PreprocessingInfo::before)
 Attach an arbitrary string to a located node. A workaround to insert irregular statements or vendor-specific attributes. More...
 
ROSE_DLL_API void replaceMacroCallsWithExpandedStrings (SgPragmaDeclaration *target)
 Check if a pragma declaration node has macro calls attached, if yes, replace macro calls within the pragma string with expanded strings. This only works if -rose:wave is turned on. More...
 
Source File Position

set Sg_File_Info for a SgNode

ROSE_DLL_API PreprocessingInfoattachComment (SgLocatedNode *target, const std::string &content, PreprocessingInfo::RelativePositionType position=PreprocessingInfo::before, PreprocessingInfo::DirectiveType dtype=PreprocessingInfo::CpreprocessorUnknownDeclaration)
 Build and attach comment, comment style is inferred from the language type of the target node if not provided. More...
 
ROSE_DLL_API void addTextForUnparser (SgNode *astNode, std::string s, AstUnparseAttribute::RelativePositionType inputlocation)
 Add a string to be unparsed to support code generation for back-end specific tools or compilers. More...
 
void setSourcePosition (SgNode *node)
 Set the source code positon for the current (input) node. More...
 
void setSourcePositionAtRootAndAllChildren (SgNode *root)
 Set the source code positon for the subtree (including the root). More...
 
template<class T >
void setSourcePositionToDefault (T *node)
 Set subtree as a transformation. More...
 
void setSourcePositionAsTransformation (SgNode *node)
 DQ (5/1/2012): New function with improved name. More...
 
void setSourcePositionPointersToNull (SgNode *node)
 Build and attach comment, comment style is inferred from the language type of the target node if not provided. More...
 
ROSE_DLL_API void setOneSourcePositionForTransformation (SgNode *node)
 Set current node's source position as transformation generated. More...
 
ROSE_DLL_API void setOneSourcePositionNull (SgNode *node)
 Set current node's source position as NULL. More...
 
ROSE_DLL_API void setSourcePositionForTransformation (SgNode *root)
 Recursively set source position info(Sg_File_Info) as transformation generated. More...
 
ROSE_DLL_API void setSourcePositionForTransformation_memoryPool ()
 Set source position info(Sg_File_Info) as transformation generated for all SgNodes in memory pool. More...
 
Data types

Set the source position of SgLocatedNode to Sg_File_Info::generateDefaultFileInfo(). These nodes WILL be unparsed. Not for transformation usage.

SgTypegetBoolType (SgNode *n)
 Get the right bool type according to C or C++ language input. More...
 
ROSE_DLL_API bool isStrictIntegerType (SgType *t)
 
Check if a type is an integral type, only allowing signed/unsigned short, int, long, long long.

/! /! There is another similar function named SgType::isIntegerType(), which allows additional types char, wchar, and bool to be treated as integer types More...

 
ROSE_DLL_API SgTypegetFirstVarType (SgVariableDeclaration *decl)
 Get the data type of the first initialized name of a declaration statement. More...
 
ROSE_DLL_API bool isDefaultConstructible (SgType *type)
 Is a type default constructible? This may not quite work properly. More...
 
ROSE_DLL_API bool isCopyConstructible (SgType *type)
 Is a type copy constructible? This may not quite work properly. More...
 
ROSE_DLL_API bool isAssignable (SgType *type)
 Is a type assignable? This may not quite work properly. More...
 
ROSE_DLL_API bool isPureVirtualClass (SgType *type, const ClassHierarchyWrapper &classHierarchy)
 Check if a class type is a pure virtual class. More...
 
ROSE_DLL_API bool hasTrivialDestructor (SgType *t)
 Does a type have a trivial (built-in) destructor? More...
 
ROSE_DLL_API bool isNonconstReference (SgType *t)
 Is this type a non-constant reference type? (Handles typedefs correctly) More...
 
ROSE_DLL_API bool isReferenceType (SgType *t)
 Is this type a const or non-const reference type? (Handles typedefs correctly) More...
 
ROSE_DLL_API bool isPointerType (SgType *t)
 Is this type a pointer type? (Handles typedefs correctly) More...
 
ROSE_DLL_API bool isPointerToNonConstType (SgType *type)
 Is this a pointer to a non-const type? Note that this function will return true for const pointers pointing to non-const types. More...
 
ROSE_DLL_API bool isConstType (SgType *t)
 Is this a const type? More...
 
SgTyperemoveConst (SgType *t)
 Remove const (if present) from a type. stripType() cannot do this because it removes all modifiers. More...
 
ROSE_DLL_API bool isVolatileType (SgType *t)
 Is this a volatile type? More...
 
ROSE_DLL_API bool isRestrictType (SgType *t)
 Is this a restrict type? More...
 
ROSE_DLL_API bool isScalarType (SgType *t)
 Is this a scalar type? More...
 
ROSE_DLL_API bool isStructType (SgType *t)
 Check if a type is a struct type (a special SgClassType in ROSE) More...
 
ROSE_DLL_API std::string mangleType (SgType *type)
 Generate a mangled string for a given type based on Itanium C++ ABI. More...
 
ROSE_DLL_API std::string mangleScalarType (SgType *type)
 Generate mangled scalar type names according to Itanium C++ ABI, the input type should pass isScalarType() in ROSE. More...
 
ROSE_DLL_API std::string mangleModifierType (SgModifierType *type)
 Generated mangled modifier types, include const, volatile,according to Itanium C++ ABI, with extension to handle UPC shared types. More...
 
ROSE_DLL_API size_t getArrayElementCount (SgArrayType *t)
 Calculate the number of elements of an array type: dim1* dim2*... , assume element count is 1 for int a[]; Strip off THREADS if it is a UPC array. More...
 
ROSE_DLL_API int getDimensionCount (SgType *t)
 Get the number of dimensions of an array type. More...
 
ROSE_DLL_API SgTypegetArrayElementType (SgType *t)
 Get the element type of an array. More...
 
ROSE_DLL_API SgTypegetElementType (SgType *t)
 Get the element type of an array, pointer or string, or NULL if not applicable. More...
 
std::vector< SgExpression * > get_C_array_dimensions (const SgArrayType &arrtype)
 returns the array dimensions in an array as defined for arrtype More...
 
std::vector< SgExpression * > get_C_array_dimensions (const SgArrayType &arrtype, const SgVarRefExp &varref)
 returns the array dimensions in an array as defined for arrtype More...
 
std::vector< SgExpression * > get_C_array_dimensions (const SgArrayType &arrtype, SgInitializedName &initname)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
ROSE_DLL_API bool isArrayReference (SgExpression *ref, SgExpression **arrayNameExp=NULL, std::vector< SgExpression * > **subscripts=NULL)
 Check if an expression is an array access (SgPntrArrRefExp). If so, return its name expression and subscripts if requested. Users can use convertRefToInitializedName() to get the possible name. It does not check if the expression is a top level SgPntrArrRefExp. More...
 
ROSE_DLL_API bool hasUpcSharedType (SgType *t, SgModifierType **mod_type_out=NULL)
 Has a UPC shared type of any kinds (shared-to-shared, private-to-shared, shared-to-private, shared scalar/array)? An optional parameter, mod_type_out, stores the first SgModifierType with UPC access information. More...
 
ROSE_DLL_API bool isUpcSharedType (SgType *t, SgModifierType **mod_type_out=NULL)
 Check if a type is a UPC shared type, including shared array, shared pointers etc. Exclude private pointers to shared types. Optionally return the modifier type with the UPC shared property. More...
 
ROSE_DLL_API bool isUpcSharedModifierType (SgModifierType *mod_type)
 Check if a modifier type is a UPC shared type. More...
 
ROSE_DLL_API bool isUpcSharedArrayType (SgArrayType *array_type)
 Check if an array type is a UPC shared type. ROSE AST represents a UPC shared array as regular array of elements of UPC shared Modifier Type. Not directly a UPC shared Modifier Type of an array. More...
 
ROSE_DLL_API bool isUpcStrictSharedModifierType (SgModifierType *mode_type)
 Check if a shared UPC type is strict memory consistency or not. Return false if it is relaxed. (So isUpcRelaxedSharedModifierType() is not necessary.) More...
 
ROSE_DLL_API size_t getUpcSharedBlockSize (SgModifierType *mod_type)
 Get the block size of a UPC shared modifier type. More...
 
ROSE_DLL_API size_t getUpcSharedBlockSize (SgType *t)
 Get the block size of a UPC shared type, including Modifier types and array of modifier types (shared arrays) More...
 
ROSE_DLL_API bool isUpcPhaseLessSharedType (SgType *t)
 Is UPC phase-less shared type? Phase-less means block size of the first SgModifierType with UPC information is 1 or 0/unspecified. Also return false if the type is not a UPC shared type. More...
 
ROSE_DLL_API bool isUpcPrivateToSharedType (SgType *t)
 Is a UPC private-to-shared pointer? SgPointerType comes first compared to SgModifierType with UPC information. Input type must be any of UPC shared types first. More...
 
ROSE_DLL_API bool isUpcArrayWithThreads (SgArrayType *t)
 Is a UPC array with dimension of X*THREADS. More...
 
ROSE_DLL_API SgTypelookupNamedTypeInParentScopes (const std::string &type_name, SgScopeStatement *scope=NULL)
 Lookup a named type based on its name, bottomup searching from a specified scope. Note name collison might be allowed for c (not C++) between typedef and enum/struct. Only the first matched named type will be returned in this case. typedef is returned as it is, not the base type it actually refers to. More...
 
Loop handling
ROSE_DLL_API void addStepToLoopBody (SgScopeStatement *loopStmt, SgStatement *step)
 Add a step statement to the end of a loop body Add a new label to the end of the loop, with the step statement after it; then change all continue statements in the old loop body into jumps to the label. More...
 
ROSE_DLL_API void moveForStatementIncrementIntoBody (SgForStatement *f)
 Add a step statement to the end of a loop body Add a new label to the end of the loop, with the step statement after it; then change all continue statements in the old loop body into jumps to the label. More...
 
ROSE_DLL_API void convertForToWhile (SgForStatement *f)
 Add a step statement to the end of a loop body Add a new label to the end of the loop, with the step statement after it; then change all continue statements in the old loop body into jumps to the label. More...
 
ROSE_DLL_API void convertAllForsToWhiles (SgNode *top)
 Add a step statement to the end of a loop body Add a new label to the end of the loop, with the step statement after it; then change all continue statements in the old loop body into jumps to the label. More...
 
ROSE_DLL_API void changeContinuesToGotos (SgStatement *stmt, SgLabelStatement *label)
 Change continue statements in a given block of code to gotos to a label. More...
 
ROSE_DLL_API SgInitializedNamegetLoopIndexVariable (SgNode *loop)
 Return the loop index variable for a for loop. More...
 
ROSE_DLL_API bool isLoopIndexVariable (SgInitializedName *ivar, SgNode *subtree_root)
 Check if a SgInitializedName is used as a loop index within a AST subtree This function will use a bottom-up traverse starting from the subtree_root to find all enclosing loops and check if ivar is used as an index for either of them. More...
 
ROSE_DLL_API SgStatementgetLoopBody (SgScopeStatement *loop)
 Routines to get and set the body of a loop. More...
 
ROSE_DLL_API void setLoopBody (SgScopeStatement *loop, SgStatement *body)
 Add a step statement to the end of a loop body Add a new label to the end of the loop, with the step statement after it; then change all continue statements in the old loop body into jumps to the label. More...
 
ROSE_DLL_API SgStatementgetLoopCondition (SgScopeStatement *loop)
 Routines to get the condition of a loop. It recognize While-loop, For-loop, and Do-While-loop. More...
 
ROSE_DLL_API void setLoopCondition (SgScopeStatement *loop, SgStatement *cond)
 Set the condition statement of a loop, including While-loop, For-loop, and Do-While-loop. More...
 
ROSE_DLL_API bool isCanonicalForLoop (SgNode *loop, SgInitializedName **ivar=NULL, SgExpression **lb=NULL, SgExpression **ub=NULL, SgExpression **step=NULL, SgStatement **body=NULL, bool *hasIncrementalIterationSpace=NULL, bool *isInclusiveUpperBound=NULL)
 Check if a for-loop has a canonical form, return loop index, bounds, step, and body if requested. More...
 
ROSE_DLL_API bool isCanonicalDoLoop (SgFortranDo *loop, SgInitializedName **ivar, SgExpression **lb, SgExpression **ub, SgExpression **step, SgStatement **body, bool *hasIncrementalIterationSpace, bool *isInclusiveUpperBound)
 Check if a Fortran Do loop has a complete canonical form: Do I=1, 10, 1. More...
 
ROSE_DLL_API void setLoopLowerBound (SgNode *loop, SgExpression *lb)
 Set the lower bound of a loop header for (i=lb; ...) More...
 
ROSE_DLL_API void setLoopUpperBound (SgNode *loop, SgExpression *ub)
 Set the upper bound of a loop header,regardless the condition expression type. for (i=lb; i op up, ...) More...
 
ROSE_DLL_API void setLoopStride (SgNode *loop, SgExpression *stride)
 Set the stride(step) of a loop 's incremental expression, regardless the expression types (i+=s; i= i+s, etc) More...
 
ROSE_DLL_API bool normalizeForLoopInitDeclaration (SgForStatement *loop)
 Normalize loop init stmt by promoting the single variable declaration statement outside of the for loop header's init statement, e.g. for (int i=0;) becomes int i_x; for (i_x=0;..) and rewrite the loop with the new index variable, if necessary. More...
 
ROSE_DLL_API bool forLoopNormalization (SgForStatement *loop)
 Normalize a for loop, return true if successful. More...
 
ROSE_DLL_API bool doLoopNormalization (SgFortranDo *loop)
 Normalize a Fortran Do loop. Make the default increment expression (1) explicit. More...
 
ROSE_DLL_API bool loopUnrolling (SgForStatement *loop, size_t unrolling_factor)
 Unroll a target loop with a specified unrolling factor. It handles steps larger than 1 and adds a fringe loop if the iteration count is not evenly divisible by the unrolling factor. More...
 
ROSE_DLL_API bool loopInterchange (SgForStatement *loop, size_t depth, size_t lexicoOrder)
 Interchange/permutate a n-level perfectly-nested loop rooted at 'loop' using a lexicographical order number within (0,depth!). More...
 
ROSE_DLL_API bool loopTiling (SgForStatement *loopNest, size_t targetLevel, size_t tileSize)
 Tile the n-level (starting from 1) loop of a perfectly nested loop nest using tiling size s. More...
 
SgExprListExploopCollapsing (SgForStatement *target_loop, size_t collapsing_factor)
 Add a step statement to the end of a loop body Add a new label to the end of the loop, with the step statement after it; then change all continue statements in the old loop body into jumps to the label. More...
 
Topdown search

Top-down traversal from current node to find a node of a specified type

template<typename NodeType >
std::vector< NodeType * > querySubTree (SgNode *top, VariantT variant=(VariantT) NodeType::static_variant)
 Query a subtree to get all nodes of a given type, with an appropriate downcast. More...
 
std::vector< SgFile * > generateFileList ()
 Returns STL vector of SgFile IR node pointers. More...
 
ROSE_DLL_API SgProjectgetProject ()
 Get the current SgProject IR Node. More...
 
template<typename NodeType >
static std::vector< NodeType * > getSgNodeListFromMemoryPool ()
 Query memory pools to grab SgNode of a specified type. More...
 
ROSE_DLL_API
SgFunctionDeclaration
findMain (SgNode *currentNode)
 top-down traversal from current node to find the main() function declaration More...
 
SgStatementfindLastDeclarationStatement (SgScopeStatement *scope)
 Find the last declaration statement within a scope (if any). This is often useful to decide where to insert another declaration statement. More...
 
std::vector< SgVariableSymbol * > getSymbolsUsedInExpression (SgExpression *expr)
 Find referenced symbols within an expression. More...
 
std::vector< SgBreakStmt * > findBreakStmts (SgStatement *code, const std::string &fortranLabel="")
 Find break statements inside a particular statement, stopping at nested loops or switches. More...
 
std::vector< SgContinueStmt * > findContinueStmts (SgStatement *code, const std::string &fortranLabel="")
 Find all continue statements inside a particular statement, stopping at nested loops. More...
 
std::vector< SgGotoStatement * > findGotoStmts (SgStatement *scope, SgLabelStatement *l)
 Query a subtree to get all nodes of a given type, with an appropriate downcast. More...
 
std::vector< SgStatement * > getSwitchCases (SgSwitchStatement *sw)
 Query a subtree to get all nodes of a given type, with an appropriate downcast. More...
 
template<typename T >
T * findDeclarationStatement (SgNode *root, std::string name, SgScopeStatement *scope, bool isDefining)
 Topdown traverse a subtree from root to find the first declaration given its name, scope (optional, can be NULL), and defining or nondefining flag. More...
 
SgFunctionDeclarationfindFunctionDeclaration (SgNode *root, std::string name, SgScopeStatement *scope, bool isDefining)
 Topdown traverse a subtree from root to find the first function declaration matching the given name, scope (optional, can be NULL), and defining or nondefining flag. This is an instantiation of findDeclarationStatement<T>. More...
 
Bottom up search

Backwards traverse through the AST to find a node, findEnclosingXXX()

template<typename NodeType >
NodeType * getEnclosingNode (const SgNode *astNode, const bool includingSelf=false)
 Find a node by type using upward traversal. More...
 
ROSE_DLL_API SgSourceFilegetEnclosingSourceFile (SgNode *n, const bool includingSelf=false)
 Find enclosing source file node. More...
 
ROSE_DLL_API SgScopeStatementgetScope (const SgNode *astNode)
 Get the closest scope from astNode. Return astNode if it is already a scope. More...
 
ROSE_DLL_API SgScopeStatementgetEnclosingScope (SgNode *n, const bool includingSelf=false)
 Get the enclosing scope from a node n. More...
 
ROSE_DLL_API SgGlobalgetGlobalScope (const SgNode *astNode)
 Traverse back through a node's parents to find the enclosing global scope. More...
 
ROSE_DLL_API SgFunctionDefinitiongetEnclosingProcedure (SgNode *n, const bool includingSelf=false)
 Find the function definition. More...
 
ROSE_DLL_API SgFunctionDefinitiongetEnclosingFunctionDefinition (SgNode *astNode, const bool includingSelf=false)
 Find a node by type using upward traversal. More...
 
ROSE_DLL_API SgStatementgetEnclosingStatement (SgNode *n)
 Find the closest enclosing statement, including the given node. More...
 
ROSE_DLL_API SgSwitchStatementfindEnclosingSwitch (SgStatement *s)
 Find the closest switch outside a given statement (normally used for case and default statements) More...
 
ROSE_DLL_API SgScopeStatementfindEnclosingLoop (SgStatement *s, const std::string &fortranLabel="", bool stopOnSwitches=false)
 Find the closest loop outside the given statement; if fortranLabel is not empty, the Fortran label of the loop must be equal to it. More...
 
ROSE_DLL_API
SgFunctionDeclaration
getEnclosingFunctionDeclaration (SgNode *astNode, const bool includingSelf=false)
 Find the enclosing function declaration, including its derived instances like isSgProcedureHeaderStatement, isSgProgramHeaderStatement, and isSgMemberFunctionDeclaration. More...
 
ROSE_DLL_API SgFilegetEnclosingFileNode (SgNode *astNode)
 get the SgFile node from current node More...
 
ROSE_DLL_API SgInitializergetInitializerOfExpression (SgExpression *n)
 Get the initializer containing an expression if it is within an initializer. More...
 
ROSE_DLL_API SgClassDefinitiongetEnclosingClassDefinition (SgNode *astnode, const bool includingSelf=false)
 Get the closest class definition enclosing the specified AST node,. More...
 
AST Walk and Traversal
ROSE_DLL_API SgGlobalgetFirstGlobalScope (SgProject *project)
 return the first global scope under current project More...
 
ROSE_DLL_API SgStatementgetLastStatement (SgScopeStatement *scope)
 get the last statement within a scope, return NULL if it does not exit More...
 
ROSE_DLL_API SgStatementgetFirstStatement (SgScopeStatement *scope, bool includingCompilerGenerated=false)
 Get the first statement within a scope, return NULL if it does not exist. Skip compiler-generated statement by default. Count transformation-generated ones, but excluding those which are not to be outputted in unparsers. More...
 
ROSE_DLL_API
SgFunctionDeclaration
findFirstDefiningFunctionDecl (SgScopeStatement *scope)
 Find the first defining function declaration statement in a scope. More...
 
ROSE_DLL_API SgStatementgetNextStatement (SgStatement *currentStmt)
 Get next statement within the same scope of current statement. More...
 
ROSE_DLL_API SgStatementgetPreviousStatement (SgStatement *currentStmt)
 Get previous statement within the same scope of current statement. More...
 
AST Comparison

Compare AST nodes, subtree, etc

ROSE_DLL_API bool isEqualToIntConst (SgExpression *e, int value)
 Check if a SgIntVal node has a given value. More...
 
ROSE_DLL_API bool isSameFunction (SgFunctionDeclaration *func1, SgFunctionDeclaration *func2)
 Check if two function declarations refer to the same one. Two function declarations are the same when they are a) identical, b) same name in C c) same qualified named and mangled name in C++. A nondefining (prototype) declaration and a defining declaration of a same function are treated as the same. More...
 
ROSE_DLL_API bool isLastStatement (SgStatement *stmt)
 Check if a statement is the last statement within its closed scope. More...
 
AST insert, removal, and replacement

Add, remove,and replace AST

scope->append_statement(), exprListExp->append_expression() etc. are not enough to handle side effect of parent pointers, symbol tables, preprocessing info, defining/nondefining pointers etc.

ROSE_DLL_API void deleteAST (SgNode *node)
 Function to delete AST subtree's nodes only, users must take care of any dangling pointers, symbols or types that result. More...
 
ROSE_DLL_API void deleteExpressionTreeWithOriginalExpressionSubtrees (SgNode *root)
 Special purpose function for deleting AST expression tress containing valid original expression trees in constant folded expressions (for internal use only). More...
 
ROSE_DLL_API void moveStatementsBetweenBlocks (SgBasicBlock *sourceBlock, SgBasicBlock *targetBlock)
 Move statements in first block to the second block (preserves order and rebuilds the symbol table). More...
 
ROSE_DLL_API void appendStatement (SgStatement *stmt, SgScopeStatement *scope=NULL)
 Append a statement to the end of the current scope, handle side effect of appending statements, e.g. preprocessing info, defining/nondefining pointers etc. More...
 
ROSE_DLL_API void appendStatementList (const std::vector< SgStatement * > &stmt, SgScopeStatement *scope=NULL)
 Append a list of statements to the end of the current scope, handle side effect of appending statements, e.g. preprocessing info, defining/nondefining pointers etc. More...
 
ROSE_DLL_API void appendStatementWithDependentDeclaration (SgDeclarationStatement *decl, SgGlobal *scope, SgStatement *original_statement, bool excludeHeaderFiles)
 Append a copy ('decl') of a function ('original_statement') into a 'scope', include any referenced declarations required if the scope is within a compiler generated file. All referenced declarations, including those from headers, are inserted if excludeHeaderFiles is set to true (the new file will not have any headers). More...
 
ROSE_DLL_API void prependStatement (SgStatement *stmt, SgScopeStatement *scope=NULL)
 Prepend a statement to the beginning of the current scope, handling side effects as appropriate. More...
 
ROSE_DLL_API void prependStatementList (const std::vector< SgStatement * > &stmt, SgScopeStatement *scope=NULL)
 prepend a list of statements to the beginning of the current scope, handling side effects as appropriate More...
 
ROSE_DLL_API bool hasSimpleChildrenList (SgScopeStatement *scope)
 Check if a scope statement has a simple children statement list so insert additional statements under the scope is straightforward and unambiguous . More...
 
ROSE_DLL_API void insertStatement (SgStatement *targetStmt, SgStatement *newStmt, bool insertBefore=true, bool autoMovePreprocessingInfo=true)
 Insert a statement before or after the target statement within the target's scope. Move around preprocessing info automatically. More...
 
ROSE_DLL_API void insertStatementList (SgStatement *targetStmt, const std::vector< SgStatement * > &newStmts, bool insertBefore=true)
 Insert a list of statements before or after the target statement within the. More...
 
ROSE_DLL_API void insertStatementBefore (SgStatement *targetStmt, SgStatement *newStmt, bool autoMovePreprocessingInfo=true)
 Insert a statement before a target statement. More...
 
ROSE_DLL_API void insertStatementListBefore (SgStatement *targetStmt, const std::vector< SgStatement * > &newStmts)
 Insert a list of statements before a target statement. More...
 
ROSE_DLL_API void insertStatementAfter (SgStatement *targetStmt, SgStatement *newStmt, bool autoMovePreprocessingInfo=true)
 Insert a statement after a target statement, Move around preprocessing info automatically by default. More...
 
ROSE_DLL_API void insertStatementListAfter (SgStatement *targetStmt, const std::vector< SgStatement * > &newStmt)
 Insert a list of statements after a target statement. More...
 
ROSE_DLL_API void insertStatementAfterLastDeclaration (SgStatement *stmt, SgScopeStatement *scope)
 Insert a statement after the last declaration within a scope. The statement will be prepended to the scope if there is no declaration statement found. More...
 
ROSE_DLL_API void insertStatementAfterLastDeclaration (std::vector< SgStatement * > stmt_list, SgScopeStatement *scope)
 Insert a list of statements after the last declaration within a scope. The statement will be prepended to the scope if there is no declaration statement found. More...
 
ROSE_DLL_API void insertStatementBeforeFirstNonDeclaration (SgStatement *newStmt, SgScopeStatement *scope, bool movePreprocessingInfo=true)
 Insert a statement before the first non-declaration statement in a scope. If the scope has no non-declaration statements. More...
 
ROSE_DLL_API void insertStatementListBeforeFirstNonDeclaration (const std::vector< SgStatement * > &newStmts, SgScopeStatement *scope)
 Insert statements before the first non-declaration statement in a scope. If the scope has no non-declaration statements. More...
 
ROSE_DLL_API void removeStatement (SgStatement *stmt, bool autoRelocatePreprocessingInfo=true)
 Remove a statement from its attach point of the AST. Automatically keep its associated preprocessing information at the original place after the removal. The statement is still in memory and it is up to the users to decide if the removed one will be inserted somewhere else or released from memory (deleteAST()). More...
 
ROSE_DLL_API void deepDelete (SgNode *root)
 Deep delete a sub AST tree. It uses postorder traversal to delete each child node. Users must take care of any dangling pointers, symbols or types that result. This is identical to deleteAST() More...
 
ROSE_DLL_API void replaceStatement (SgStatement *oldStmt, SgStatement *newStmt, bool movePreprocessinInfo=false)
 Replace a statement with another. Move preprocessing information from oldStmt to newStmt if requested. More...
 
ROSE_DLL_API SgNodereplaceWithPattern (SgNode *anchor, SgNode *new_pattern)
 Replace an anchor node with a specified pattern subtree with optional SgVariantExpression. All SgVariantExpression in the pattern will be replaced with copies of the anchor node. More...
 
std::pair
< SgVariableDeclaration
*, SgExpression * > 
createTempVariableForExpression (SgExpression *expression, SgScopeStatement *scope, bool initializeInDeclaration, SgAssignOp **reEvaluate=NULL)
 Given an expression, generates a temporary variable whose initializer optionally evaluates that expression. More...
 
std::pair
< SgVariableDeclaration
*, SgExpression * > 
createTempVariableAndReferenceForExpression (SgExpression *expression, SgScopeStatement *scope)
 Function to delete AST subtree's nodes only, users must take care of any dangling pointers, symbols or types that result. More...
 
ROSE_DLL_API SgVariableSymbolappendArg (SgFunctionParameterList *, SgInitializedName *)
 Append an argument to SgFunctionParameterList, transparently set parent,scope, and symbols for arguments when possible. More...
 
ROSE_DLL_API SgVariableSymbolprependArg (SgFunctionParameterList *, SgInitializedName *)
 Prepend an argument to SgFunctionParameterList. More...
 
ROSE_DLL_API void appendExpression (SgExprListExp *, SgExpression *)
 Append an expression to a SgExprListExp, set the parent pointer also. More...
 
ROSE_DLL_API void appendExpressionList (SgExprListExp *, const std::vector< SgExpression * > &)
 Append an expression list to a SgExprListExp, set the parent pointers also. More...
 
template<class actualFunction >
ROSE_DLL_API void setParameterList (actualFunction *func, SgFunctionParameterList *paralist)
 Set parameter list for a function declaration, considering existing parameter list etc. More...
 
template<class actualFunction >
void setParameterList (actualFunction *func, SgFunctionParameterList *paralist)
 Set parameter list for a function declaration, considering existing parameter list etc. More...
 
ROSE_DLL_API void setPragma (SgPragmaDeclaration *decl, SgPragma *pragma)
 Set a pragma of a pragma declaration. handle memory release for preexisting pragma, and set parent pointer. More...
 
ROSE_DLL_API void replaceExpression (SgExpression *oldExp, SgExpression *newExp, bool keepOldExp=false)
 Replace an expression with another, used for variable reference substitution and others. the old expression can be deleted (default case) or kept. More...
 
ROSE_DLL_API void replaceExpressionWithStatement (SgExpression *from, SageInterface::StatementGenerator *to)
 Replace a given expression with a list of statements produced by a generator. More...
 
ROSE_DLL_API void replaceSubexpressionWithStatement (SgExpression *from, SageInterface::StatementGenerator *to)
 Similar to replaceExpressionWithStatement, but with more restrictions. More...
 
ROSE_DLL_API void setOperand (SgExpression *target, SgExpression *operand)
 Set operands for expressions with single operand, such as unary expressions. handle file info, lvalue, pointer downcasting, parent pointer etc. More...
 
ROSE_DLL_API void setLhsOperand (SgExpression *target, SgExpression *lhs)
 set left hand operand for binary expressions, transparently downcasting target expressions when necessary More...
 
ROSE_DLL_API void setRhsOperand (SgExpression *target, SgExpression *rhs)
 set left hand operand for binary expression More...
 
ROSE_DLL_API void removeAllOriginalExpressionTrees (SgNode *top)
 Set original expression trees to NULL for SgValueExp or SgCastExp expressions, so you can change the value and have it unparsed correctly. More...
 
ROSE_DLL_API void moveToSubdirectory (std::string directoryName, SgFile *file)
 Move file to be generated in a subdirectory (will be generated by the unparser). More...
 
ROSE_DLL_API SgStatementfindSurroundingStatementFromSameFile (SgStatement *targetStmt, bool &surroundingStatementPreceedsTargetStatement)
 Supporting function to comment relocation in insertStatement() and removeStatement(). More...
 
ROSE_DLL_API void moveCommentsToNewStatement (SgStatement *sourceStatement, const std::vector< int > &indexList, SgStatement *targetStatement, bool surroundingStatementPreceedsTargetStatement)
 Relocate comments and CPP directives from one statement to another. More...
 
AST repair, fix, and postprocessing.

Mostly used internally when some AST pieces are built without knowing their target scope/parent, especially during bottom-up construction of AST. The associated symbols, parent and scope pointers cannot be set on construction then. A set of utility functions are provided to patch up scope, parent, symbol for them when the target scope/parent become know.

ROSE_DLL_API int fixVariableReferences (SgNode *root)
 Connect variable reference to the right variable symbols when feasible, return the number of references being fixed. More...
 
void fixVariableDeclaration (SgVariableDeclaration *varDecl, SgScopeStatement *scope)
 Patch up symbol, scope, and parent information when a SgVariableDeclaration's scope is known. More...
 
void fixStructDeclaration (SgClassDeclaration *structDecl, SgScopeStatement *scope)
 Fix symbols, parent and scope pointers. Used internally within appendStatment(), insertStatement() etc when a struct declaration was built without knowing its target scope. More...
 
void fixClassDeclaration (SgClassDeclaration *classDecl, SgScopeStatement *scope)
 Fix symbols, parent and scope pointers. Used internally within appendStatment(), insertStatement() etc when a class declaration was built without knowing its target scope. More...
 
void fixNamespaceDeclaration (SgNamespaceDeclarationStatement *structDecl, SgScopeStatement *scope)
 Fix symbols, parent and scope pointers. Used internally within appendStatment(), insertStatement() etc when a namespace declaration was built without knowing its target scope. More...
 
void fixLabelStatement (SgLabelStatement *label_stmt, SgScopeStatement *scope)
 Fix symbol table for SgLabelStatement. Used Internally when the label is built without knowing its target scope. Both parameters cannot be NULL. More...
 
void setFortranNumericLabel (SgStatement *stmt, int label_value)
 Set a numerical label for a Fortran statement. The statement should have a enclosing function definition already. SgLabelSymbol and SgLabelRefExp are created transparently as needed. More...
 
int suggestNextNumericLabel (SgFunctionDefinition *func_def)
 Suggest next usable (non-conflicting) numeric label value for a Fortran function definition scope. More...
 
void fixFunctionDeclaration (SgFunctionDeclaration *stmt, SgScopeStatement *scope)
 Fix the symbol table and set scope (only if scope in declaration is not already set). More...
 
void fixTemplateDeclaration (SgTemplateDeclaration *stmt, SgScopeStatement *scope)
 Fix the symbol table and set scope (only if scope in declaration is not already set). More...
 
void fixStatement (SgStatement *stmt, SgScopeStatement *scope)
 A wrapper containing fixes (fixVariableDeclaration(),fixStructDeclaration(), fixLabelStatement(), etc) for all kinds statements. Should be used before attaching the statement into AST. More...
 
Advanced AST transformations, analyses, and optimizations

Some complex but commonly used AST transformations.

ROSE_DLL_API bool collectReadWriteRefs (SgStatement *stmt, std::vector< SgNode * > &readRefs, std::vector< SgNode * > &writeRefs, bool useCachedDefUse=false)
 Collect all read and write references within stmt, which can be a function, a scope statement, or a single statement. Note that a reference can be both read and written, like i++. More...
 
ROSE_DLL_API bool collectReadWriteVariables (SgStatement *stmt, std::set< SgInitializedName * > &readVars, std::set< SgInitializedName * > &writeVars)
 Collect unique variables which are read or written within a statement. Note that a variable can be both read and written. The statement can be either of a function, a scope, or a single line statement. More...
 
ROSE_DLL_API void collectReadOnlyVariables (SgStatement *stmt, std::set< SgInitializedName * > &readOnlyVars)
 Collect read only variables within a statement. The statement can be either of a function, a scope, or a single line statement. More...
 
ROSE_DLL_API void collectReadOnlySymbols (SgStatement *stmt, std::set< SgVariableSymbol * > &readOnlySymbols)
 Collect read only variable symbols within a statement. The statement can be either of a function, a scope, or a single line statement. More...
 
ROSE_DLL_API bool isUseByAddressVariableRef (SgVarRefExp *ref)
 Check if a variable reference is used by its address: including &a expression and foo(a) when type2 foo(Type& parameter) in C++. More...
 
ROSE_DLL_API void collectUseByAddressVariableRefs (const SgStatement *s, std::set< SgVarRefExp * > &varSetB)
 Collect variable references involving use by address: including &a expression and foo(a) when type2 foo(Type& parameter) in C++. More...
 
ROSE_DLL_API LivenessAnalysiscall_liveness_analysis (SgProject *project, bool debug=false)
 Call liveness analysis on an entire project. More...
 
ROSE_DLL_API void getLiveVariables (LivenessAnalysis *liv, SgForStatement *loop, std::set< SgInitializedName * > &liveIns, std::set< SgInitializedName * > &liveOuts)
 get liveIn and liveOut variables for a for loop from liveness analysis result liv. More...
 
ROSE_DLL_API void ReductionRecognition (SgForStatement *loop, std::set< std::pair< SgInitializedName *, VariantT > > &results)
 Recognize and collect reduction variables and operations within a C/C++ loop, following OpenMP 3.0 specification for allowed reduction variable types and operation types. More...
 
ROSE_DLL_API void constantFolding (SgNode *r)
 Constant folding an AST subtree rooted at 'r' (replacing its children with their constant values, if applicable). Please be advised that constant folding on floating point computation may decrease the accuracy of floating point computations! More...
 
ROSE_DLL_API int instrumentEndOfFunction (SgFunctionDeclaration *func, SgStatement *s)
 Instrument(Add a statement, often a function call) into a function right before the return points, handle multiple return statements and return expressions with side effects. Return the number of statements inserted. More...
 
ROSE_DLL_API void removeJumpsToNextStatement (SgNode *)
 Remove jumps whose label is immediately after the jump. Used to clean up inlined code fragments. More...
 
ROSE_DLL_API void removeUnusedLabels (SgNode *top)
 Remove labels which are not targets of any goto statements. More...
 
ROSE_DLL_API void removeConsecutiveLabels (SgNode *top)
 Remove consecutive labels. More...
 
ROSE_DLL_API SgAssignInitializersplitExpression (SgExpression *from, std::string newName="")
 Replace an expression with a temporary variable and an assignment statement. More...
 
ROSE_DLL_API void splitExpressionIntoBasicBlock (SgExpression *expr)
 Split long expressions into blocks of statements. More...
 
ROSE_DLL_API void removeLabeledGotos (SgNode *top)
 Remove labeled goto statements. More...
 
ROSE_DLL_API void changeBreakStatementsToGotos (SgStatement *loopOrSwitch)
 If the given statement contains any break statements in its body, add a new label below the statement and change the breaks into gotos to that new label. More...
 
ROSE_DLL_API SgBasicBlockensureBasicBlockAsBodyOfFor (SgForStatement *fs)
 Check if the body of a 'for' statement is a SgBasicBlock, create one if not. More...
 
ROSE_DLL_API SgBasicBlockensureBasicBlockAsBodyOfUpcForAll (SgUpcForAllStatement *fs)
 Check if the body of a 'upc_forall' statement is a SgBasicBlock, create one if not. More...
 
ROSE_DLL_API SgBasicBlockensureBasicBlockAsBodyOfWhile (SgWhileStmt *ws)
 Check if the body of a 'while' statement is a SgBasicBlock, create one if not. More...
 
ROSE_DLL_API SgBasicBlockensureBasicBlockAsBodyOfDoWhile (SgDoWhileStmt *ws)
 Check if the body of a 'do .. while' statement is a SgBasicBlock, create one if not. More...
 
ROSE_DLL_API SgBasicBlockensureBasicBlockAsBodyOfSwitch (SgSwitchStatement *ws)
 Check if the body of a 'switch' statement is a SgBasicBlock, create one if not. More...
 
SgBasicBlockensureBasicBlockAsBodyOfCaseOption (SgCaseOptionStmt *cs)
 Check if the body of a 'case option' statement is a SgBasicBlock, create one if not. More...
 
SgBasicBlockensureBasicBlockAsBodyOfDefaultOption (SgDefaultOptionStmt *cs)
 Check if the body of a 'default option' statement is a SgBasicBlock, create one if not. More...
 
ROSE_DLL_API SgBasicBlockensureBasicBlockAsTrueBodyOfIf (SgIfStmt *ifs)
 Check if the true body of a 'if' statement is a SgBasicBlock, create one if not. More...
 
ROSE_DLL_API SgBasicBlockensureBasicBlockAsFalseBodyOfIf (SgIfStmt *ifs)
 Check if the false body of a 'if' statement is a SgBasicBlock, create one if not. More...
 
ROSE_DLL_API SgBasicBlockensureBasicBlockAsBodyOfCatch (SgCatchOptionStmt *cos)
 Check if the body of a 'catch' statement is a SgBasicBlock, create one if not. More...
 
ROSE_DLL_API SgBasicBlockensureBasicBlockAsBodyOfOmpBodyStmt (SgOmpBodyStatement *ompbodyStmt)
 Check if the body of a SgOmpBodyStatement is a SgBasicBlock, create one if not. More...
 
bool isBodyStatement (SgStatement *s)
 Check if a statement is a (true or false) body of a container-like parent, such as For, Upc_forall, Do-while, switch, If, Catch, OmpBodyStmt, etc. More...
 
void changeAllBodiesToBlocks (SgNode *top)
 Fix up ifs, loops, while, switch, Catch, OmpBodyStatement, etc. to have blocks as body components. It also adds an empty else body to if statements that don't have them. More...
 
void changeAllLoopBodiesToBlocks (SgNode *top)
 The same as changeAllBodiesToBlocks(SgNode* top). To be phased out. More...
 
SgBasicBlockmakeSingleStatementBodyToBlock (SgStatement *singleStmt)
 Make a single statement body to be a basic block. Its parent is if, while, catch, or upc_forall etc. More...
 
unsigned long long getIntegerConstantValue (SgValueExp *expr)
 Get the constant value from a constant integer expression; abort on everything else. More...
 
std::vector
< SgDeclarationStatement * > 
getDependentDeclarations (SgStatement *stmt)
 Get a statement's dependent declarations which declares the types used in the statement. The returned vector of declaration statements are sorted according to their appearance order in the original AST. Any reference to a class or template class from a namespace will treated as a reference to the enclosing namespace. More...
 
SgCommaOpExpinsertBeforeUsingCommaOp (SgExpression *new_exp, SgExpression *anchor_exp)
 Insert an expression (new_exp )before another expression (anchor_exp) has possible side effects, without changing the original semantics. This is achieved by using a comma operator: (new_exp, anchor_exp). The comma operator is returned. More...
 
SgCommaOpExpinsertAfterUsingCommaOp (SgExpression *new_exp, SgExpression *anchor_exp, SgStatement **temp_decl=NULL, SgVarRefExp **temp_ref=NULL)
 Insert an expression (new_exp ) after another expression (anchor_exp) has possible side effects, without changing the original semantics. This is done by using two comma operators: type T1; ... ((T1 = anchor_exp, new_exp),T1) )... , where T1 is a temp variable saving the possible side effect of anchor_exp. The top level comma op exp is returned. The reference to T1 in T1 = anchor_exp is saved in temp_ref. More...
 
std::pair< SgStatement
*, SgInitializedName * > 
wrapFunction (SgFunctionDeclaration &definingDeclaration, SgName newName)
 moves the body of a function f to a new function f; f's body is replaced with code that forwards the call to f. More...
 
template<class NameGen >
std::pair< SgStatement
*, SgInitializedName * > 
wrapFunction (SgFunctionDeclaration &definingDeclaration, NameGen nameGen)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
SgInitializedNamegetFirstVariable (SgVariableDeclaration &vardecl)
 convenience function that returns the first initialized name in a list of variable declarations. More...
 

Variables

ROSE_DLL_API int gensym_counter
 An internal counter for generating unique SgName. More...
 

Typedef Documentation

typedef bool(* SageInterface::EquivalenceTestFunctionType)(SgNode *x, SgNode *y)

Definition at line 36 of file sageInterfaceAsm.h.

Function Documentation

DeclarationSets* SageInterface::buildDeclarationSets ( SgNode )
SgAsmInterpretation* SageInterface::getMainInterpretation ( SgAsmGenericFile file)
uint64_t SageInterface::getAsmConstant ( SgAsmValueExpression e)

Get the unsigned value of a disassembled constant.

Referenced by SgAsmArmInstruction::get_successors(), and SgAsmPowerpcInstruction::get_successors().

int64_t SageInterface::getAsmSignedConstant ( SgAsmValueExpression e)

Get the signed value of a disassembled constant.

void SageInterface::addMessageStatement ( SgStatement stmt,
std::string  message 
)

Function to add "C" style comment to statement.

void SageInterface::supplementReplacementSymbolMap ( rose_hash::unordered_map< SgNode *, SgNode *, hash_nodeptr > &  inputReplacementMap)
ROSE_DLL_API SgVariableSymbol* SageInterface::lookupVariableSymbolInParentScopes ( const SgName name,
SgScopeStatement currentScope = NULL 
)

Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeStack if currentscope is not given or NULL.

ROSE_DLL_API SgSymbol* SageInterface::lookupSymbolInParentScopes ( const SgName name,
SgScopeStatement currentScope = NULL,
SgTemplateParameterPtrList templateParameterList = NULL,
SgTemplateArgumentPtrList templateArgumentList = NULL 
)

Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeStack if currentscope is not given or NULL.

ROSE_DLL_API SgFunctionSymbol* SageInterface::lookupFunctionSymbolInParentScopes ( const SgName functionName,
SgScopeStatement currentScope = NULL 
)

look up the first matched function symbol in parent scopes given only a function name, starting from top of ScopeStack if currentscope is not given or NULL

ROSE_DLL_API SgFunctionSymbol* SageInterface::lookupFunctionSymbolInParentScopes ( const SgName functionName,
const SgType t,
SgScopeStatement currentScope = NULL 
)

look up function symbol in parent scopes given both name and function type, starting from top of ScopeStack if currentscope is not given or NULL

ROSE_DLL_API SgClassSymbol* SageInterface::lookupClassSymbolInParentScopes ( const SgName name,
SgScopeStatement currentScope = NULL,
SgTemplateArgumentPtrList templateArgumentList = NULL 
)

Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeStack if currentscope is not given or NULL.

ROSE_DLL_API SgTypedefSymbol* SageInterface::lookupTypedefSymbolInParentScopes ( const SgName name,
SgScopeStatement currentScope = NULL 
)

Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeStack if currentscope is not given or NULL.

ROSE_DLL_API SgTemplateClassSymbol* SageInterface::lookupTemplateClassSymbolInParentScopes ( const SgName name,
SgTemplateParameterPtrList templateParameterList,
SgTemplateArgumentPtrList templateArgumentList,
SgScopeStatement cscope = NULL 
)

Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeStack if currentscope is not given or NULL.

ROSE_DLL_API SgEnumSymbol* SageInterface::lookupEnumSymbolInParentScopes ( const SgName name,
SgScopeStatement currentScope = NULL 
)

Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeStack if currentscope is not given or NULL.

ROSE_DLL_API SgNamespaceSymbol* SageInterface::lookupNamespaceSymbolInParentScopes ( const SgName name,
SgScopeStatement currentScope = NULL 
)

Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeStack if currentscope is not given or NULL.

ROSE_DLL_API int SageInterface::set_name ( SgInitializedName initializedNameNode,
SgName  new_name 
)

set_name of symbol in symbol table.

This function extracts the symbol from the relavant symbol table, changes the name (at the declaration) and reinserts it into the symbol table.

I think this is what this function does, I need to double check.

Referenced by SgAsmElfSection::allocate_name_to_storage(), SgAsmNEFileHeader::ctor(), SgAsmElfSectionTable::ctor(), SgAsmElfSegmentTable::ctor(), SgAsmNESectionTable::ctor(), SgAsmNENameTable::ctor(), SgAsmNEModuleTable::ctor(), SgAsmNEStringTable::ctor(), SgAsmNEEntryTable::ctor(), SgAsmNERelocTable::ctor(), SgAsmElfSymbol::ctor(), SgAsmElfDynamicEntry::ctor(), MemoryMap::Segment::merge_names(), and MemoryMap::Segment::set_name().

void SageInterface::outputGlobalFunctionTypeSymbolTable ( )

Output function type symbols in global function type symbol table.

ROSE_DLL_API void SageInterface::outputLocalSymbolTables ( SgNode node)

Output the local symbol tables.

Each symbol table is output with the file infor where it is located in the source code.

void SageInterface::rebuildSymbolTable ( SgScopeStatement scope)

Regenerate the symbol table.

current symbol table must be NULL pointer before calling this function (for safety, but is this a good idea?)

void SageInterface::clearUnusedVariableSymbols ( SgNode root = NULL)

Clear those variable symbols with unknown type (together with initialized names) which are also not referenced by any variable references or declarations under root. If root is NULL, all symbols with unknown type will be deleted.

void SageInterface::fixupReferencesToSymbols ( const SgScopeStatement this_scope,
SgScopeStatement copy_scope,
SgCopyHelp help 
)

All the symbol table references in the copied AST need to be reset after rebuilding the copied scope's symbol table.

std::string SageInterface::get_name ( const SgNode node)
std::string SageInterface::get_name ( const SgStatement stmt)

Generate a useful name to describe the declaration.

default names are used for declarations that can not be associated with a name.

std::string SageInterface::get_name ( const SgExpression expr)

Generate a useful name to describe the expression.

default names are used for expressions that can not be associated with a name.

std::string SageInterface::get_name ( const SgDeclarationStatement declaration)

Generate a useful name to describe the declaration.

default names are used for declarations that can not be associated with a name.

std::string SageInterface::get_name ( const SgScopeStatement scope)

Generate a useful name to describe the scope.

default names are used for scope that cannot be associated with a name.

std::string SageInterface::get_name ( const SgSymbol symbol)

Generate a useful name to describe the SgSymbol.

default names are used for SgSymbol objects that cannot be associated with a name.

std::string SageInterface::get_name ( const SgType type)

Generate a useful name to describe the SgType.

default names are used for SgType objects that cannot be associated with a name.

std::string SageInterface::get_name ( const SgSupport node)

Generate a useful name to describe the SgSupport IR node.

std::string SageInterface::get_name ( const SgLocatedNodeSupport node)

Generate a useful name to describe the SgLocatedNodeSupport IR node.

std::string SageInterface::get_name ( const SgC_PreprocessorDirectiveStatement directive)

Generate a useful name to describe the SgC_PreprocessorDirectiveStatement IR node.

std::string SageInterface::get_name ( const SgToken token)

Generate a useful name to describe the SgToken IR node.

SgMemberFunctionDeclaration* SageInterface::getDefaultDestructor ( SgClassDeclaration classDeclaration)

Get the default destructor from the class declaration.

ROSE_DLL_API SgMemberFunctionDeclaration* SageInterface::getDefaultConstructor ( SgClassDeclaration classDeclaration)

Get the default constructor from the class declaration.

bool SageInterface::templateDefinitionIsInClass ( SgTemplateInstantiationMemberFunctionDecl memberFunctionDeclaration)

Return true if template definition is in the class, false if outside of class.

SgTemplateInstantiationMemberFunctionDecl* SageInterface::buildForwardFunctionDeclaration ( SgTemplateInstantiationMemberFunctionDecl memberFunctionInstantiation)

Generate a non-defining (forward) declaration from a defining function declaration.

should put into sageBuilder ?

bool SageInterface::isStructDeclaration ( SgNode node)

Check if a SgNode is a declaration for a structure.

bool SageInterface::isUnionDeclaration ( SgNode node)

Check if a SgNode is a declaration for a union.

void SageInterface::whereAmI ( SgNode node)

Diagnostic function for tracing back through the parent list to understand at runtime where in the AST a failure happened.

std::string SageInterface::extractPragmaKeyword ( const SgPragmaDeclaration )

Extract a SgPragmaDeclaration's leading keyword . For example "#pragma omp parallel" has a keyword of "omp".

ROSE_DLL_API bool SageInterface::isOmpStatement ( SgNode )

Check if a node is SgOmp*Statement.

bool SageInterface::isOverloaded ( SgFunctionDeclaration functionDeclaration)

Return true if function is overloaded.

void SageInterface::initializeIfStmt ( SgIfStmt ifstmt,
SgStatement conditional,
SgStatement true_body,
SgStatement false_body 
)

Support function used for variable declarations in conditionals.

void SageInterface::initializeSwitchStatement ( SgSwitchStatement switchStatement,
SgStatement item_selector,
SgStatement body 
)

Support function used for variable declarations in conditionals.

void SageInterface::initializeWhileStatement ( SgWhileStmt whileStatement,
SgStatement condition,
SgStatement body,
SgStatement else_body 
)

Support function used for variable declarations in conditionals.

void SageInterface::annotateExpressionsWithUniqueNames ( SgProject project)

Generate unique names for expressions and attach the names as persistent attributes ("UniqueNameAttribute")

ROSE_DLL_API bool SageInterface::isMain ( const SgNode node)

Check if a SgNode is a main() function declaration.

std::string SageInterface::generateUniqueName ( const SgNode node,
bool  ignoreDifferenceBetweenDefiningAndNondefiningDeclarations 
)

Generate unique name from C and C++ constructs. The name may contain space.

This is support for the AST merge, but is generally useful as a more general mechanism than name mangling which is more closely ties to the generation of names to support link-time function name resolution. This is more general than common name mangling in that it resolves more relevant differences between C and C++ declarations. (e.g. the type within the declaration: "struct { int:8; } foo;").

current work does not support expressions.

std::string SageInterface::generateUniqueVariableName ( SgScopeStatement scope,
std::string  baseName = "temp" 
)

Generate a name that is unique in the current scope and any parent and children scopes.

Parameters
baseNamethe word to be included in the variable names.
std::string SageInterface::declarationPositionString ( const SgDeclarationStatement declaration)

Generate a unique string from the source file position information.

ROSE_DLL_API std::string SageInterface::generateProjectName ( const SgProject project,
bool  supressSuffix = false 
)

Added mechanism to generate project name from list of file names.

SgFunctionDeclaration* SageInterface::getDeclarationOfNamedFunction ( SgExpression func)

Given a SgExpression that represents a named function (or bound member function), return the mentioned function.

SgExpression* SageInterface::forallMaskExpression ( SgForAllStatement stmt)

Get the mask expression from the header of a SgForAllStatement.

void SageInterface::addVarRefExpFromArrayDimInfo ( SgNode astNode,
Rose_STL_Container< SgNode * > &  NodeList_t 
)

Find all SgPntrArrRefExp under astNode, then add SgVarRefExp (if any) of SgPntrArrRefExp's dim_info into NodeList_t.

void SageInterface::clearMangledNameCache ( SgGlobal globalScope)

Support for faster mangled name generation (caching avoids recomputation).

void SageInterface::resetMangledNameCache ( SgGlobal globalScope)

Diagnostic function for tracing back through the parent list to understand at runtime where in the AST a failure happened.

std::string SageInterface::getMangledNameFromCache ( SgNode astNode)

Diagnostic function for tracing back through the parent list to understand at runtime where in the AST a failure happened.

std::string SageInterface::addMangledNameToCache ( SgNode astNode,
const std::string &  mangledName 
)

Diagnostic function for tracing back through the parent list to understand at runtime where in the AST a failure happened.

SgDeclarationStatement* SageInterface::getNonInstantiatonDeclarationForClass ( SgTemplateInstantiationMemberFunctionDecl memberFunctionInstantiation)

Diagnostic function for tracing back through the parent list to understand at runtime where in the AST a failure happened.

void SageInterface::setBaseTypeDefiningDeclaration ( SgVariableDeclaration var_decl,
SgDeclarationStatement base_decl 
)

a better version for SgVariableDeclaration::set_baseTypeDefininingDeclaration(), handling all side effects automatically Used to have a struct declaration embedded into a variable declaration

bool SageInterface::declarationPreceedsDefinition ( SgDeclarationStatement nonDefiningDeclaration,
SgDeclarationStatement definingDeclaration 
)

Check if a defining declaration comes before of after the non-defining declaration.

bool SageInterface::functionCallExpressionPreceedsDeclarationWhichAssociatesScope ( SgFunctionCallExp functionCall)

Diagnostic function for tracing back through the parent list to understand at runtime where in the AST a failure happened.

ROSE_DLL_API std::vector< SgNode * > SageInterface::astIntersection ( SgNode original,
SgNode copy,
SgCopyHelp help = NULL 
)

Compute the intersection set for two ASTs.

This is part of a test done by the copy function to compute those IR nodes in the copy that still reference the original AST.

ROSE_DLL_API SgNode* SageInterface::deepCopyNode ( const SgNode subtree)

Deep copy an arbitrary subtree.

Referenced by deepCopy().

template<typename NodeType >
NodeType* SageInterface::deepCopy ( const NodeType *  subtree)

A template function for deep copying a subtree. It is also used to create deepcopy functions with specialized parameter and return types. e.g SgExpression* copyExpression(SgExpression* e);.

Definition at line 519 of file sageInterface.h.

References deepCopyNode().

Referenced by sg::cloneNode().

ROSE_DLL_API SgExpression* SageInterface::copyExpression ( SgExpression e)

Deep copy an expression.

ROSE_DLL_API SgStatement* SageInterface::copyStatement ( SgStatement s)

Deep copy a statement.

ROSE_DLL_API SgVariableSymbol* SageInterface::getFirstVarSym ( SgVariableDeclaration decl)

Get the variable symbol for the first initialized name of a declaration stmt.

ROSE_DLL_API SgInitializedName* SageInterface::getFirstInitializedName ( SgVariableDeclaration decl)

Get the first initialized name of a declaration statement.

ROSE_DLL_API void SageInterface::myRemoveStatement ( SgStatement stmt)

A special purpose statement removal function, originally from inlinerSupport.h, Need Jeremiah's attention to refine it. Please don't use it for now.

ROSE_DLL_API bool SageInterface::isConstantTrue ( SgExpression e)

Diagnostic function for tracing back through the parent list to understand at runtime where in the AST a failure happened.

ROSE_DLL_API bool SageInterface::isConstantFalse ( SgExpression e)

Diagnostic function for tracing back through the parent list to understand at runtime where in the AST a failure happened.

ROSE_DLL_API bool SageInterface::isCallToParticularFunction ( SgFunctionDeclaration decl,
SgExpression e 
)

Diagnostic function for tracing back through the parent list to understand at runtime where in the AST a failure happened.

ROSE_DLL_API bool SageInterface::isCallToParticularFunction ( const std::string &  qualifiedName,
size_t  arity,
SgExpression e 
)

Diagnostic function for tracing back through the parent list to understand at runtime where in the AST a failure happened.

bool ROSE_DLL_API SageInterface::isStatic ( SgDeclarationStatement stmt)

Check if a declaration has a "static' modifier.

ROSE_DLL_API void SageInterface::setStatic ( SgDeclarationStatement stmt)

Set a declaration as static.

ROSE_DLL_API bool SageInterface::isExtern ( SgDeclarationStatement stmt)

Check if a declaration has an "extern" modifier.

ROSE_DLL_API void SageInterface::setExtern ( SgDeclarationStatement stmt)

Set a declaration as extern.

bool SageInterface::isAssignmentStatement ( SgNode _s,
SgExpression **  lhs = NULL,
SgExpression **  rhs = NULL,
bool *  readlhs = NULL 
)

Check if a SgNode _s is an assignment statement (any of =,+=,-=,&=,/=, ^=, etc)

Return the left hand, right hand expressions and if the left hand variable is also being read

ROSE_DLL_API SgInitializedName* SageInterface::convertRefToInitializedName ( SgNode current)

Variable references can be introduced by SgVarRef, SgPntrArrRefExp, SgInitializedName, SgMemberFunctionRef etc. This function will convert them all to a top level SgInitializedName.

ROSE_DLL_API AbstractHandle::abstract_handle* SageInterface::buildAbstractHandle ( SgNode )

Build an abstract handle from an AST node, reuse previously built handle when possible.

ROSE_DLL_API SgNode* SageInterface::getSgNodeFromAbstractHandleString ( const std::string &  input_string)

Obtain a matching SgNode from an abstract handle string.

ROSE_DLL_API void SageInterface::dumpInfo ( SgNode node,
std::string  desc = "" 
)

Dump information about a SgNode for debugging.

ROSE_DLL_API std::vector<SgDeclarationStatement*> SageInterface::sortSgNodeListBasedOnAppearanceOrderInSource ( const std::vector< SgDeclarationStatement * > &  nodevec)

Reorder a list of declaration statements based on their appearance order in source files.

bool SageInterface::isPrefixOperator ( SgExpression exp)

Is an overloaded operator a prefix operator (e.g. address operator X * operator&(), dereference operator X & operator*(), unary plus operator X & operator+(), etc.

bool SageInterface::isPrefixOperatorName ( const SgName functionName)

Check for proper names of possible prefix operators (used in isPrefixOperator()).

bool SageInterface::isPostfixOperator ( SgExpression exp)

Is an overloaded operator a postfix operator. (e.g. ).

bool SageInterface::isIndexOperator ( SgExpression exp)

Is an overloaded operator an index operator (also referred to as call or subscript operators). (e.g. X & operator()() or X & operator[]()).

ROSE_DLL_API bool SageInterface::is_C_language ( )

Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!

ROSE_DLL_API bool SageInterface::is_OpenMP_language ( )

Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!

ROSE_DLL_API bool SageInterface::is_UPC_language ( )

Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!

ROSE_DLL_API bool SageInterface::is_UPC_dynamic_threads ( )

Check if dynamic threads compilation is used for UPC programs.

ROSE_DLL_API bool SageInterface::is_C99_language ( )

Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!

ROSE_DLL_API bool SageInterface::is_Cxx_language ( )

Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!

ROSE_DLL_API bool SageInterface::is_Java_language ( )

Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!

ROSE_DLL_API bool SageInterface::is_Fortran_language ( )

Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!

ROSE_DLL_API bool SageInterface::is_CAF_language ( )

Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!

ROSE_DLL_API bool SageInterface::is_PHP_language ( )

Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!

ROSE_DLL_API bool SageInterface::is_Python_language ( )

Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!

ROSE_DLL_API bool SageInterface::is_Cuda_language ( )

Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!

ROSE_DLL_API bool SageInterface::is_X10_language ( )

Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!

ROSE_DLL_API bool SageInterface::is_binary_executable ( )

Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!

ROSE_DLL_API bool SageInterface::is_mixed_C_and_Cxx_language ( )

Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!

ROSE_DLL_API bool SageInterface::is_mixed_Fortran_and_C_language ( )

Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!

ROSE_DLL_API bool SageInterface::is_mixed_Fortran_and_Cxx_language ( )

Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!

ROSE_DLL_API bool SageInterface::is_mixed_Fortran_and_C_and_Cxx_language ( )

Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!

void SageInterface::resetScopeNumbers ( SgFunctionDefinition functionDeclaration)

Assigns unique numbers to each SgScopeStatement of a function.

This is used to provide unique names for variables and types defined is different nested scopes of a function (used in mangled name generation).

void SageInterface::clearScopeNumbers ( SgFunctionDefinition functionDefinition)

Clears the cache of scope,integer pairs for the input function.

This is used to clear the cache of computed unique labels for scopes in a function. This function should be called after any transformation on a function that might effect the allocation of scopes and cause the existing unique numbers to be incorrect. This is part of support to provide unique names for variables and types defined is different nested scopes of a function (used in mangled name generation).

SgNamespaceDefinitionStatement* SageInterface::enclosingNamespaceScope ( SgDeclarationStatement declaration)

Find the enclosing namespace of a declaration.

bool SageInterface::isPrototypeInScope ( SgScopeStatement scope,
SgFunctionDeclaration functionDeclaration,
SgDeclarationStatement startingAtDeclaration 
)

Assigns unique numbers to each SgScopeStatement of a function.

This is used to provide unique names for variables and types defined is different nested scopes of a function (used in mangled name generation).

bool ROSE_DLL_API SageInterface::isAncestor ( SgNode node1,
SgNode node2 
)

check if node1 is a strict ancestor of node 2. (a node is not considered its own ancestor)

void SageInterface::dumpPreprocInfo ( SgLocatedNode locatedNode)

Dumps a located node's preprocessing information.

ROSE_DLL_API PreprocessingInfo* SageInterface::insertHeader ( const std::string &  filename,
PreprocessingInfo::RelativePositionType  position = PreprocessingInfo::after,
bool  isSystemHeader = false,
SgScopeStatement scope = NULL 
)

Insert #include "filename" or #include <filename> (system header) into the global scope containing the current scope, right after other #include XXX.

ROSE_DLL_API void SageInterface::moveUpPreprocessingInfo ( SgStatement stmt_dst,
SgStatement stmt_src,
PreprocessingInfo::RelativePositionType  src_position = PreprocessingInfo::undef,
PreprocessingInfo::RelativePositionType  dst_position = PreprocessingInfo::undef,
bool  usePrepend = false 
)

Identical to movePreprocessingInfo(), except for the stale name and confusing order of parameters. It will be deprecated soon.

ROSE_DLL_API void SageInterface::movePreprocessingInfo ( SgStatement stmt_src,
SgStatement stmt_dst,
PreprocessingInfo::RelativePositionType  src_position = PreprocessingInfo::undef,
PreprocessingInfo::RelativePositionType  dst_position = PreprocessingInfo::undef,
bool  usePrepend = false 
)

Move preprocessing information of stmt_src to stmt_dst, Only move preprocessing information from the specified source-relative position to a specified target position, otherwise move all preprocessing information with position information intact. The preprocessing information is appended to the existing preprocessing information list of the target node by default. Prepending is used if usePreprend is set to true. Optionally, the relative position can be adjust after the moving using dst_position.

ROSE_DLL_API void SageInterface::cutPreprocessingInfo ( SgLocatedNode src_node,
PreprocessingInfo::RelativePositionType  pos,
AttachedPreprocessingInfoType save_buf 
)

Cut preprocessing information from a source node and save it into a buffer. Used in combination of pastePreprocessingInfo(). The cut-paste operation is similar to moveUpPreprocessingInfo() but it is more flexible in that the destination node can be unknown during the cut operation.

ROSE_DLL_API void SageInterface::pastePreprocessingInfo ( SgLocatedNode dst_node,
PreprocessingInfo::RelativePositionType  pos,
AttachedPreprocessingInfoType saved_buf 
)

Paste preprocessing information from a buffer to a destination node. Used in combination of cutPreprocessingInfo()

ROSE_DLL_API PreprocessingInfo* SageInterface::attachArbitraryText ( SgLocatedNode target,
const std::string &  text,
PreprocessingInfo::RelativePositionType  position = PreprocessingInfo::before 
)

Attach an arbitrary string to a located node. A workaround to insert irregular statements or vendor-specific attributes.

ROSE_DLL_API void SageInterface::replaceMacroCallsWithExpandedStrings ( SgPragmaDeclaration target)

Check if a pragma declaration node has macro calls attached, if yes, replace macro calls within the pragma string with expanded strings. This only works if -rose:wave is turned on.

Build and attach comment, comment style is inferred from the language type of the target node if not provided.

ROSE_DLL_API void SageInterface::addTextForUnparser ( SgNode astNode,
std::string  s,
AstUnparseAttribute::RelativePositionType  inputlocation 
)

Add a string to be unparsed to support code generation for back-end specific tools or compilers.

void SageInterface::setSourcePosition ( SgNode node)

Set the source code positon for the current (input) node.

void SageInterface::setSourcePositionAtRootAndAllChildren ( SgNode root)

Set the source code positon for the subtree (including the root).

template<class T >
void SageInterface::setSourcePositionToDefault ( T *  node)

Set subtree as a transformation.

DQ (5/1/2012): New function with improved name.

void SageInterface::setSourcePositionAsTransformation ( SgNode node)

DQ (5/1/2012): New function with improved name.

void SageInterface::setSourcePositionPointersToNull ( SgNode node)

Build and attach comment, comment style is inferred from the language type of the target node if not provided.

ROSE_DLL_API void SageInterface::setOneSourcePositionForTransformation ( SgNode node)

Set current node's source position as transformation generated.

ROSE_DLL_API void SageInterface::setOneSourcePositionNull ( SgNode node)

Set current node's source position as NULL.

ROSE_DLL_API void SageInterface::setSourcePositionForTransformation ( SgNode root)

Recursively set source position info(Sg_File_Info) as transformation generated.

ROSE_DLL_API void SageInterface::setSourcePositionForTransformation_memoryPool ( )

Set source position info(Sg_File_Info) as transformation generated for all SgNodes in memory pool.

SgType* SageInterface::getBoolType ( SgNode n)

Get the right bool type according to C or C++ language input.

ROSE_DLL_API bool SageInterface::isStrictIntegerType ( SgType t)

Check if a type is an integral type, only allowing signed/unsigned short, int, long, long long.

/! /! There is another similar function named SgType::isIntegerType(), which allows additional types char, wchar, and bool to be treated as integer types

Check if a type is an integral type, only allowing signed/unsigned short, int, long, long long.

There is another similar function named SgType::isIntegerType(), which allows additional types char, wchar, and bool.

ROSE_DLL_API SgType* SageInterface::getFirstVarType ( SgVariableDeclaration decl)

Get the data type of the first initialized name of a declaration statement.

ROSE_DLL_API bool SageInterface::isDefaultConstructible ( SgType type)

Is a type default constructible? This may not quite work properly.

ROSE_DLL_API bool SageInterface::isCopyConstructible ( SgType type)

Is a type copy constructible? This may not quite work properly.

ROSE_DLL_API bool SageInterface::isAssignable ( SgType type)

Is a type assignable? This may not quite work properly.

ROSE_DLL_API bool SageInterface::isPureVirtualClass ( SgType type,
const ClassHierarchyWrapper classHierarchy 
)

Check if a class type is a pure virtual class.

True means that there is at least one pure virtual function that has not been overridden. In the case of an incomplete class type (forward declaration), this function returns false.

ROSE_DLL_API bool SageInterface::hasTrivialDestructor ( SgType t)

Does a type have a trivial (built-in) destructor?

ROSE_DLL_API bool SageInterface::isNonconstReference ( SgType t)

Is this type a non-constant reference type? (Handles typedefs correctly)

ROSE_DLL_API bool SageInterface::isReferenceType ( SgType t)

Is this type a const or non-const reference type? (Handles typedefs correctly)

ROSE_DLL_API bool SageInterface::isPointerType ( SgType t)

Is this type a pointer type? (Handles typedefs correctly)

ROSE_DLL_API bool SageInterface::isPointerToNonConstType ( SgType type)

Is this a pointer to a non-const type? Note that this function will return true for const pointers pointing to non-const types.

For example, (int* const y) points to a modifiable int, so this function returns true. Meanwhile, it returns false for (int const * x) and (int const * const x) because these types point to a const int. Also, only the outer layer of nested pointers is unwrapped. So the function returns true for (const int ** y), but returns false for const (int * const * x)

ROSE_DLL_API bool SageInterface::isConstType ( SgType t)

Is this a const type?

SgType* SageInterface::removeConst ( SgType t)

Remove const (if present) from a type. stripType() cannot do this because it removes all modifiers.

ROSE_DLL_API bool SageInterface::isVolatileType ( SgType t)

Is this a volatile type?

ROSE_DLL_API bool SageInterface::isRestrictType ( SgType t)

Is this a restrict type?

ROSE_DLL_API bool SageInterface::isScalarType ( SgType t)

Is this a scalar type?

We define the following SgType as scalar types: char, short, int, long , void, Wchar, Float, double, long long, string, bool, complex, imaginary

ROSE_DLL_API bool SageInterface::isStructType ( SgType t)

Check if a type is a struct type (a special SgClassType in ROSE)

ROSE_DLL_API std::string SageInterface::mangleType ( SgType type)

Generate a mangled string for a given type based on Itanium C++ ABI.

ROSE_DLL_API std::string SageInterface::mangleScalarType ( SgType type)

Generate mangled scalar type names according to Itanium C++ ABI, the input type should pass isScalarType() in ROSE.

ROSE_DLL_API std::string SageInterface::mangleModifierType ( SgModifierType type)

Generated mangled modifier types, include const, volatile,according to Itanium C++ ABI, with extension to handle UPC shared types.

ROSE_DLL_API size_t SageInterface::getArrayElementCount ( SgArrayType t)

Calculate the number of elements of an array type: dim1* dim2*... , assume element count is 1 for int a[]; Strip off THREADS if it is a UPC array.

ROSE_DLL_API int SageInterface::getDimensionCount ( SgType t)

Get the number of dimensions of an array type.

ROSE_DLL_API SgType* SageInterface::getArrayElementType ( SgType t)

Get the element type of an array.

ROSE_DLL_API SgType* SageInterface::getElementType ( SgType t)

Get the element type of an array, pointer or string, or NULL if not applicable.

std::vector<SgExpression*> SageInterface::get_C_array_dimensions ( const SgArrayType arrtype)

returns the array dimensions in an array as defined for arrtype

Parameters
arrtypethe type of a C/C++ array
Returns
an array that contains an expression indicating each dimension's size. OWNERSHIP of the expressions is TRANSFERED TO the CALLER (which becomes responsible for freeing the expressions). Note, the first entry of the array is a SgNullExpression, iff the first array dimension was not specified.
int x[] = { 1, 2, 3 };
note, the expression does not have to be a constant
int x[i*5];
Postcondition
return-value.empty() == false
return-value[*] != NULL (no nullptr in the returned vector)
std::vector<SgExpression*> SageInterface::get_C_array_dimensions ( const SgArrayType arrtype,
const SgVarRefExp varref 
)

returns the array dimensions in an array as defined for arrtype

Parameters
arrtypethe type of a C/C++ array
varrefa reference to an array variable (the variable of type arrtype)
Returns
an array that contains an expression indicating each dimension's size. OWNERSHIP of the expressions is TRANSFERED TO the CALLER (which becomes responsible for freeing the expressions). If the first array dimension was not specified an expression that indicates that size is generated.
int x[][3] = { 1, 2, 3, 4, 5, 6 };
the entry for the first dimension will be:
// 3 ... size of 2nd dimension
sizeof(x) / (sizeof(int) * 3)
Precondition
arrtype is the array-type of varref
Postcondition
return-value.empty() == false
return-value[*] != NULL (no nullptr in the returned vector)
!isSgNullExpression(return-value[*])
std::vector<SgExpression*> SageInterface::get_C_array_dimensions ( const SgArrayType arrtype,
SgInitializedName initname 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Note
see get_C_array_dimensions for SgVarRefExp for details.
Todo:
make initname const
ROSE_DLL_API bool SageInterface::isArrayReference ( SgExpression ref,
SgExpression **  arrayNameExp = NULL,
std::vector< SgExpression * > **  subscripts = NULL 
)

Check if an expression is an array access (SgPntrArrRefExp). If so, return its name expression and subscripts if requested. Users can use convertRefToInitializedName() to get the possible name. It does not check if the expression is a top level SgPntrArrRefExp.

ROSE_DLL_API bool SageInterface::hasUpcSharedType ( SgType t,
SgModifierType **  mod_type_out = NULL 
)

Has a UPC shared type of any kinds (shared-to-shared, private-to-shared, shared-to-private, shared scalar/array)? An optional parameter, mod_type_out, stores the first SgModifierType with UPC access information.

Note: we classify private-to-shared as 'has shared' type for convenience here. It is indeed a private type in strict sense. AST graph for some examples:

ROSE_DLL_API bool SageInterface::isUpcSharedType ( SgType t,
SgModifierType **  mod_type_out = NULL 
)

Check if a type is a UPC shared type, including shared array, shared pointers etc. Exclude private pointers to shared types. Optionally return the modifier type with the UPC shared property.

ROSE uses SgArrayType of SgModifierType to represent shared arrays, not SgModifierType points to SgArrayType. Also typedef may cause a chain of nodes before reach the actual SgModifierType with UPC shared property.

ROSE_DLL_API bool SageInterface::isUpcSharedModifierType ( SgModifierType mod_type)

Check if a modifier type is a UPC shared type.

ROSE_DLL_API bool SageInterface::isUpcSharedArrayType ( SgArrayType array_type)

Check if an array type is a UPC shared type. ROSE AST represents a UPC shared array as regular array of elements of UPC shared Modifier Type. Not directly a UPC shared Modifier Type of an array.

ROSE_DLL_API bool SageInterface::isUpcStrictSharedModifierType ( SgModifierType mode_type)

Check if a shared UPC type is strict memory consistency or not. Return false if it is relaxed. (So isUpcRelaxedSharedModifierType() is not necessary.)

ROSE_DLL_API size_t SageInterface::getUpcSharedBlockSize ( SgModifierType mod_type)

Get the block size of a UPC shared modifier type.

ROSE_DLL_API size_t SageInterface::getUpcSharedBlockSize ( SgType t)

Get the block size of a UPC shared type, including Modifier types and array of modifier types (shared arrays)

ROSE_DLL_API bool SageInterface::isUpcPhaseLessSharedType ( SgType t)

Is UPC phase-less shared type? Phase-less means block size of the first SgModifierType with UPC information is 1 or 0/unspecified. Also return false if the type is not a UPC shared type.

ROSE_DLL_API bool SageInterface::isUpcPrivateToSharedType ( SgType t)

Is a UPC private-to-shared pointer? SgPointerType comes first compared to SgModifierType with UPC information. Input type must be any of UPC shared types first.

ROSE_DLL_API bool SageInterface::isUpcArrayWithThreads ( SgArrayType t)

Is a UPC array with dimension of X*THREADS.

ROSE_DLL_API SgType* SageInterface::lookupNamedTypeInParentScopes ( const std::string &  type_name,
SgScopeStatement scope = NULL 
)

Lookup a named type based on its name, bottomup searching from a specified scope. Note name collison might be allowed for c (not C++) between typedef and enum/struct. Only the first matched named type will be returned in this case. typedef is returned as it is, not the base type it actually refers to.

ROSE_DLL_API void SageInterface::addStepToLoopBody ( SgScopeStatement loopStmt,
SgStatement step 
)

Add a step statement to the end of a loop body Add a new label to the end of the loop, with the step statement after it; then change all continue statements in the old loop body into jumps to the label.

For example: while (a < 5) {if (a < -3) continue;} (adding "a++" to end) becomes while (a < 5) {if (a < -3) goto label; label: a++;}

ROSE_DLL_API void SageInterface::moveForStatementIncrementIntoBody ( SgForStatement f)

Add a step statement to the end of a loop body Add a new label to the end of the loop, with the step statement after it; then change all continue statements in the old loop body into jumps to the label.

For example: while (a < 5) {if (a < -3) continue;} (adding "a++" to end) becomes while (a < 5) {if (a < -3) goto label; label: a++;}

ROSE_DLL_API void SageInterface::convertForToWhile ( SgForStatement f)

Add a step statement to the end of a loop body Add a new label to the end of the loop, with the step statement after it; then change all continue statements in the old loop body into jumps to the label.

For example: while (a < 5) {if (a < -3) continue;} (adding "a++" to end) becomes while (a < 5) {if (a < -3) goto label; label: a++;}

ROSE_DLL_API void SageInterface::convertAllForsToWhiles ( SgNode top)

Add a step statement to the end of a loop body Add a new label to the end of the loop, with the step statement after it; then change all continue statements in the old loop body into jumps to the label.

For example: while (a < 5) {if (a < -3) continue;} (adding "a++" to end) becomes while (a < 5) {if (a < -3) goto label; label: a++;}

ROSE_DLL_API void SageInterface::changeContinuesToGotos ( SgStatement stmt,
SgLabelStatement label 
)

Change continue statements in a given block of code to gotos to a label.

ROSE_DLL_API SgInitializedName* SageInterface::getLoopIndexVariable ( SgNode loop)

Return the loop index variable for a for loop.

ROSE_DLL_API bool SageInterface::isLoopIndexVariable ( SgInitializedName ivar,
SgNode subtree_root 
)

Check if a SgInitializedName is used as a loop index within a AST subtree This function will use a bottom-up traverse starting from the subtree_root to find all enclosing loops and check if ivar is used as an index for either of them.

ROSE_DLL_API SgStatement* SageInterface::getLoopBody ( SgScopeStatement loop)

Routines to get and set the body of a loop.

ROSE_DLL_API void SageInterface::setLoopBody ( SgScopeStatement loop,
SgStatement body 
)

Add a step statement to the end of a loop body Add a new label to the end of the loop, with the step statement after it; then change all continue statements in the old loop body into jumps to the label.

For example: while (a < 5) {if (a < -3) continue;} (adding "a++" to end) becomes while (a < 5) {if (a < -3) goto label; label: a++;}

ROSE_DLL_API SgStatement* SageInterface::getLoopCondition ( SgScopeStatement loop)

Routines to get the condition of a loop. It recognize While-loop, For-loop, and Do-While-loop.

ROSE_DLL_API void SageInterface::setLoopCondition ( SgScopeStatement loop,
SgStatement cond 
)

Set the condition statement of a loop, including While-loop, For-loop, and Do-While-loop.

ROSE_DLL_API bool SageInterface::isCanonicalForLoop ( SgNode loop,
SgInitializedName **  ivar = NULL,
SgExpression **  lb = NULL,
SgExpression **  ub = NULL,
SgExpression **  step = NULL,
SgStatement **  body = NULL,
bool *  hasIncrementalIterationSpace = NULL,
bool *  isInclusiveUpperBound = NULL 
)

Check if a for-loop has a canonical form, return loop index, bounds, step, and body if requested.

A canonical form is defined as : one initialization statement, a test expression, and an increment expression , loop index variable should be of an integer type. IsInclusiveUpperBound is true when <= or >= is used for loop condition

ROSE_DLL_API bool SageInterface::isCanonicalDoLoop ( SgFortranDo loop,
SgInitializedName **  ivar,
SgExpression **  lb,
SgExpression **  ub,
SgExpression **  step,
SgStatement **  body,
bool *  hasIncrementalIterationSpace,
bool *  isInclusiveUpperBound 
)

Check if a Fortran Do loop has a complete canonical form: Do I=1, 10, 1.

ROSE_DLL_API void SageInterface::setLoopLowerBound ( SgNode loop,
SgExpression lb 
)

Set the lower bound of a loop header for (i=lb; ...)

ROSE_DLL_API void SageInterface::setLoopUpperBound ( SgNode loop,
SgExpression ub 
)

Set the upper bound of a loop header,regardless the condition expression type. for (i=lb; i op up, ...)

ROSE_DLL_API void SageInterface::setLoopStride ( SgNode loop,
SgExpression stride 
)

Set the stride(step) of a loop 's incremental expression, regardless the expression types (i+=s; i= i+s, etc)

ROSE_DLL_API bool SageInterface::normalizeForLoopInitDeclaration ( SgForStatement loop)

Normalize loop init stmt by promoting the single variable declaration statement outside of the for loop header's init statement, e.g. for (int i=0;) becomes int i_x; for (i_x=0;..) and rewrite the loop with the new index variable, if necessary.

ROSE_DLL_API bool SageInterface::forLoopNormalization ( SgForStatement loop)

Normalize a for loop, return true if successful.

Translations are : For the init statement: for (int i=0;... ) becomes int i; for (i=0;..) For test expression: i<x is normalized to i<= (x-1) and i>x is normalized to i>= (x+1) For increment expression: i++ is normalized to i+=1 and i– is normalized to i+=-1 i-=s is normalized to i+= -s

ROSE_DLL_API bool SageInterface::doLoopNormalization ( SgFortranDo loop)

Normalize a Fortran Do loop. Make the default increment expression (1) explicit.

ROSE_DLL_API bool SageInterface::loopUnrolling ( SgForStatement loop,
size_t  unrolling_factor 
)

Unroll a target loop with a specified unrolling factor. It handles steps larger than 1 and adds a fringe loop if the iteration count is not evenly divisible by the unrolling factor.

ROSE_DLL_API bool SageInterface::loopInterchange ( SgForStatement loop,
size_t  depth,
size_t  lexicoOrder 
)

Interchange/permutate a n-level perfectly-nested loop rooted at 'loop' using a lexicographical order number within (0,depth!).

ROSE_DLL_API bool SageInterface::loopTiling ( SgForStatement loopNest,
size_t  targetLevel,
size_t  tileSize 
)

Tile the n-level (starting from 1) loop of a perfectly nested loop nest using tiling size s.

SgExprListExp* SageInterface::loopCollapsing ( SgForStatement target_loop,
size_t  collapsing_factor 
)

Add a step statement to the end of a loop body Add a new label to the end of the loop, with the step statement after it; then change all continue statements in the old loop body into jumps to the label.

For example: while (a < 5) {if (a < -3) continue;} (adding "a++" to end) becomes while (a < 5) {if (a < -3) goto label; label: a++;}

template<typename NodeType >
std::vector<NodeType*> SageInterface::querySubTree ( SgNode top,
VariantT  variant = (VariantT)NodeType::static_variant 
)

Query a subtree to get all nodes of a given type, with an appropriate downcast.

Definition at line 1092 of file sageInterface.h.

Referenced by yicesCheck().

std::vector< SgFile * > SageInterface::generateFileList ( )

Returns STL vector of SgFile IR node pointers.

Demonstrates use of restricted traversal over just SgFile IR nodes.

ROSE_DLL_API SgProject* SageInterface::getProject ( )

Get the current SgProject IR Node.

template<typename NodeType >
static std::vector<NodeType*> SageInterface::getSgNodeListFromMemoryPool ( )
static

Query memory pools to grab SgNode of a specified type.

Definition at line 1116 of file sageInterface.h.

ROSE_DLL_API SgFunctionDeclaration* SageInterface::findMain ( SgNode currentNode)

top-down traversal from current node to find the main() function declaration

Referenced by yicesCheck().

SgStatement* SageInterface::findLastDeclarationStatement ( SgScopeStatement scope)

Find the last declaration statement within a scope (if any). This is often useful to decide where to insert another declaration statement.

std::vector<SgVariableSymbol*> SageInterface::getSymbolsUsedInExpression ( SgExpression expr)

Find referenced symbols within an expression.

std::vector<SgBreakStmt*> SageInterface::findBreakStmts ( SgStatement code,
const std::string &  fortranLabel = "" 
)

Find break statements inside a particular statement, stopping at nested loops or switches.

loops or switch statements defines their own contexts for break statements. The function will stop immediately if run on a loop or switch statement. If fortranLabel is non-empty, breaks (EXITs) to that label within nested loops are included in the returned list.

std::vector<SgContinueStmt*> SageInterface::findContinueStmts ( SgStatement code,
const std::string &  fortranLabel = "" 
)

Find all continue statements inside a particular statement, stopping at nested loops.

Nested loops define their own contexts for continue statements. The function will stop immediately if run on a loop statement. If fortranLabel is non-empty, continues (CYCLEs) to that label within nested loops are included in the returned list.

std::vector<SgGotoStatement*> SageInterface::findGotoStmts ( SgStatement scope,
SgLabelStatement l 
)

Query a subtree to get all nodes of a given type, with an appropriate downcast.

std::vector<SgStatement*> SageInterface::getSwitchCases ( SgSwitchStatement sw)

Query a subtree to get all nodes of a given type, with an appropriate downcast.

template<typename T >
T* SageInterface::findDeclarationStatement ( SgNode root,
std::string  name,
SgScopeStatement scope,
bool  isDefining 
)

Topdown traverse a subtree from root to find the first declaration given its name, scope (optional, can be NULL), and defining or nondefining flag.

Definition at line 1172 of file sageInterface.h.

References SgNode::get_traversalSuccessorContainer(), and name.

SgFunctionDeclaration* SageInterface::findFunctionDeclaration ( SgNode root,
std::string  name,
SgScopeStatement scope,
bool  isDefining 
)

Topdown traverse a subtree from root to find the first function declaration matching the given name, scope (optional, can be NULL), and defining or nondefining flag. This is an instantiation of findDeclarationStatement<T>.

template<typename NodeType >
NodeType* SageInterface::getEnclosingNode ( const SgNode astNode,
const bool  includingSelf = false 
)

Find a node by type using upward traversal.

Traverse backward through a specified node's ancestors, starting with the node's parent and progressing to more distant ancestors, to find the first node matching the specified or derived type. If includingSelf is true then the starting node, astNode, is returned if its type matches, otherwise the search starts at the parent of astNode.

For the purposes of this function, the parent (P) of an SgDeclarationStatement node (N) is considered to be the first non-defining declaration of N if N has both a defining declaration and a first non-defining declaration and the defining declaration is different than the first non-defining declaration.

If no ancestor of the requisite type of subtypes is found then this function returns a null pointer.

If astNode is the null pointer, then the return value is a null pointer. That is, if there is no node, then there cannot be an enclosing node of the specified type.

Definition at line 1254 of file sageInterface.h.

References SgNode::class_name(), SgDeclarationStatement::class_name(), Sg_File_Info::display(), SgDeclarationStatement::get_definingDeclaration(), SgLocatedNode::get_file_info(), SgDeclarationStatement::get_firstNondefiningDeclaration(), SgNode::get_parent(), and isSgDeclarationStatement().

ROSE_DLL_API SgSourceFile* SageInterface::getEnclosingSourceFile ( SgNode n,
const bool  includingSelf = false 
)

Find enclosing source file node.

ROSE_DLL_API SgScopeStatement* SageInterface::getScope ( const SgNode astNode)

Get the closest scope from astNode. Return astNode if it is already a scope.

ROSE_DLL_API SgScopeStatement* SageInterface::getEnclosingScope ( SgNode n,
const bool  includingSelf = false 
)

Get the enclosing scope from a node n.

ROSE_DLL_API SgGlobal* SageInterface::getGlobalScope ( const SgNode astNode)

Traverse back through a node's parents to find the enclosing global scope.

ROSE_DLL_API SgFunctionDefinition* SageInterface::getEnclosingProcedure ( SgNode n,
const bool  includingSelf = false 
)

Find the function definition.

ROSE_DLL_API SgFunctionDefinition* SageInterface::getEnclosingFunctionDefinition ( SgNode astNode,
const bool  includingSelf = false 
)

Find a node by type using upward traversal.

Traverse backward through a specified node's ancestors, starting with the node's parent and progressing to more distant ancestors, to find the first node matching the specified or derived type. If includingSelf is true then the starting node, astNode, is returned if its type matches, otherwise the search starts at the parent of astNode.

For the purposes of this function, the parent (P) of an SgDeclarationStatement node (N) is considered to be the first non-defining declaration of N if N has both a defining declaration and a first non-defining declaration and the defining declaration is different than the first non-defining declaration.

If no ancestor of the requisite type of subtypes is found then this function returns a null pointer.

If astNode is the null pointer, then the return value is a null pointer. That is, if there is no node, then there cannot be an enclosing node of the specified type.

ROSE_DLL_API SgStatement* SageInterface::getEnclosingStatement ( SgNode n)

Find the closest enclosing statement, including the given node.

ROSE_DLL_API SgSwitchStatement* SageInterface::findEnclosingSwitch ( SgStatement s)

Find the closest switch outside a given statement (normally used for case and default statements)

ROSE_DLL_API SgScopeStatement* SageInterface::findEnclosingLoop ( SgStatement s,
const std::string &  fortranLabel = "",
bool  stopOnSwitches = false 
)

Find the closest loop outside the given statement; if fortranLabel is not empty, the Fortran label of the loop must be equal to it.

ROSE_DLL_API SgFunctionDeclaration* SageInterface::getEnclosingFunctionDeclaration ( SgNode astNode,
const bool  includingSelf = false 
)

Find the enclosing function declaration, including its derived instances like isSgProcedureHeaderStatement, isSgProgramHeaderStatement, and isSgMemberFunctionDeclaration.

ROSE_DLL_API SgFile* SageInterface::getEnclosingFileNode ( SgNode astNode)

get the SgFile node from current node

ROSE_DLL_API SgInitializer* SageInterface::getInitializerOfExpression ( SgExpression n)

Get the initializer containing an expression if it is within an initializer.

ROSE_DLL_API SgClassDefinition* SageInterface::getEnclosingClassDefinition ( SgNode astnode,
const bool  includingSelf = false 
)

Get the closest class definition enclosing the specified AST node,.

ROSE_DLL_API SgGlobal* SageInterface::getFirstGlobalScope ( SgProject project)

return the first global scope under current project

ROSE_DLL_API SgStatement* SageInterface::getLastStatement ( SgScopeStatement scope)

get the last statement within a scope, return NULL if it does not exit

ROSE_DLL_API SgStatement* SageInterface::getFirstStatement ( SgScopeStatement scope,
bool  includingCompilerGenerated = false 
)

Get the first statement within a scope, return NULL if it does not exist. Skip compiler-generated statement by default. Count transformation-generated ones, but excluding those which are not to be outputted in unparsers.

ROSE_DLL_API SgFunctionDeclaration* SageInterface::findFirstDefiningFunctionDecl ( SgScopeStatement scope)

Find the first defining function declaration statement in a scope.

ROSE_DLL_API SgStatement* SageInterface::getNextStatement ( SgStatement currentStmt)

Get next statement within the same scope of current statement.

ROSE_DLL_API SgStatement* SageInterface::getPreviousStatement ( SgStatement currentStmt)

Get previous statement within the same scope of current statement.

ROSE_DLL_API bool SageInterface::isEqualToIntConst ( SgExpression e,
int  value 
)

Check if a SgIntVal node has a given value.

ROSE_DLL_API bool SageInterface::isSameFunction ( SgFunctionDeclaration func1,
SgFunctionDeclaration func2 
)

Check if two function declarations refer to the same one. Two function declarations are the same when they are a) identical, b) same name in C c) same qualified named and mangled name in C++. A nondefining (prototype) declaration and a defining declaration of a same function are treated as the same.

There is a similar function bool compareFunctionDeclarations(SgFunctionDeclaration *f1, SgFunctionDeclaration *f2) from Classhierarchy.C

ROSE_DLL_API bool SageInterface::isLastStatement ( SgStatement stmt)

Check if a statement is the last statement within its closed scope.

ROSE_DLL_API void SageInterface::deleteExpressionTreeWithOriginalExpressionSubtrees ( SgNode root)

Special purpose function for deleting AST expression tress containing valid original expression trees in constant folded expressions (for internal use only).

ROSE_DLL_API void SageInterface::moveStatementsBetweenBlocks ( SgBasicBlock sourceBlock,
SgBasicBlock targetBlock 
)

Move statements in first block to the second block (preserves order and rebuilds the symbol table).

ROSE_DLL_API void SageInterface::appendStatement ( SgStatement stmt,
SgScopeStatement scope = NULL 
)

Append a statement to the end of the current scope, handle side effect of appending statements, e.g. preprocessing info, defining/nondefining pointers etc.

ROSE_DLL_API void SageInterface::appendStatementList ( const std::vector< SgStatement * > &  stmt,
SgScopeStatement scope = NULL 
)

Append a list of statements to the end of the current scope, handle side effect of appending statements, e.g. preprocessing info, defining/nondefining pointers etc.

ROSE_DLL_API void SageInterface::appendStatementWithDependentDeclaration ( SgDeclarationStatement decl,
SgGlobal scope,
SgStatement original_statement,
bool  excludeHeaderFiles 
)

Append a copy ('decl') of a function ('original_statement') into a 'scope', include any referenced declarations required if the scope is within a compiler generated file. All referenced declarations, including those from headers, are inserted if excludeHeaderFiles is set to true (the new file will not have any headers).

ROSE_DLL_API void SageInterface::prependStatement ( SgStatement stmt,
SgScopeStatement scope = NULL 
)

Prepend a statement to the beginning of the current scope, handling side effects as appropriate.

ROSE_DLL_API void SageInterface::prependStatementList ( const std::vector< SgStatement * > &  stmt,
SgScopeStatement scope = NULL 
)

prepend a list of statements to the beginning of the current scope, handling side effects as appropriate

ROSE_DLL_API bool SageInterface::hasSimpleChildrenList ( SgScopeStatement scope)

Check if a scope statement has a simple children statement list so insert additional statements under the scope is straightforward and unambiguous .

for example, SgBasicBlock has a simple statement list while IfStmt does not.

ROSE_DLL_API void SageInterface::insertStatement ( SgStatement targetStmt,
SgStatement newStmt,
bool  insertBefore = true,
bool  autoMovePreprocessingInfo = true 
)

Insert a statement before or after the target statement within the target's scope. Move around preprocessing info automatically.

ROSE_DLL_API void SageInterface::insertStatementList ( SgStatement targetStmt,
const std::vector< SgStatement * > &  newStmts,
bool  insertBefore = true 
)

Insert a list of statements before or after the target statement within the.

ROSE_DLL_API void SageInterface::insertStatementBefore ( SgStatement targetStmt,
SgStatement newStmt,
bool  autoMovePreprocessingInfo = true 
)

Insert a statement before a target statement.

ROSE_DLL_API void SageInterface::insertStatementListBefore ( SgStatement targetStmt,
const std::vector< SgStatement * > &  newStmts 
)

Insert a list of statements before a target statement.

ROSE_DLL_API void SageInterface::insertStatementAfter ( SgStatement targetStmt,
SgStatement newStmt,
bool  autoMovePreprocessingInfo = true 
)

Insert a statement after a target statement, Move around preprocessing info automatically by default.

ROSE_DLL_API void SageInterface::insertStatementListAfter ( SgStatement targetStmt,
const std::vector< SgStatement * > &  newStmt 
)

Insert a list of statements after a target statement.

ROSE_DLL_API void SageInterface::insertStatementAfterLastDeclaration ( SgStatement stmt,
SgScopeStatement scope 
)

Insert a statement after the last declaration within a scope. The statement will be prepended to the scope if there is no declaration statement found.

ROSE_DLL_API void SageInterface::insertStatementAfterLastDeclaration ( std::vector< SgStatement * >  stmt_list,
SgScopeStatement scope 
)

Insert a list of statements after the last declaration within a scope. The statement will be prepended to the scope if there is no declaration statement found.

ROSE_DLL_API void SageInterface::insertStatementBeforeFirstNonDeclaration ( SgStatement newStmt,
SgScopeStatement scope,
bool  movePreprocessingInfo = true 
)

Insert a statement before the first non-declaration statement in a scope. If the scope has no non-declaration statements.

ROSE_DLL_API void SageInterface::insertStatementListBeforeFirstNonDeclaration ( const std::vector< SgStatement * > &  newStmts,
SgScopeStatement scope 
)

Insert statements before the first non-declaration statement in a scope. If the scope has no non-declaration statements.

ROSE_DLL_API void SageInterface::removeStatement ( SgStatement stmt,
bool  autoRelocatePreprocessingInfo = true 
)

Remove a statement from its attach point of the AST. Automatically keep its associated preprocessing information at the original place after the removal. The statement is still in memory and it is up to the users to decide if the removed one will be inserted somewhere else or released from memory (deleteAST()).

ROSE_DLL_API void SageInterface::deepDelete ( SgNode root)

Deep delete a sub AST tree. It uses postorder traversal to delete each child node. Users must take care of any dangling pointers, symbols or types that result. This is identical to deleteAST()

ROSE_DLL_API void SageInterface::replaceStatement ( SgStatement oldStmt,
SgStatement newStmt,
bool  movePreprocessinInfo = false 
)

Replace a statement with another. Move preprocessing information from oldStmt to newStmt if requested.

ROSE_DLL_API SgNode* SageInterface::replaceWithPattern ( SgNode anchor,
SgNode new_pattern 
)

Replace an anchor node with a specified pattern subtree with optional SgVariantExpression. All SgVariantExpression in the pattern will be replaced with copies of the anchor node.

std::pair<SgVariableDeclaration*, SgExpression* > SageInterface::createTempVariableForExpression ( SgExpression expression,
SgScopeStatement scope,
bool  initializeInDeclaration,
SgAssignOp **  reEvaluate = NULL 
)

Given an expression, generates a temporary variable whose initializer optionally evaluates that expression.

Then, the var reference expression returned can be used instead of the original expression. The temporary variable created can be reassigned to the expression by the returned SgAssignOp; this can be used when the expression the variable represents needs to be evaluated. NOTE: This handles reference types correctly by using pointer types for the temporary.

Parameters
expressionExpression which will be replaced by a variable
scopescope in which the temporary variable will be generated
reEvaluatean assignment op to reevaluate the expression. Leave NULL if not needed
Returns
declaration of the temporary variable, and a a variable reference expression to use instead of the original expression.
std::pair<SgVariableDeclaration*, SgExpression*> SageInterface::createTempVariableAndReferenceForExpression ( SgExpression expression,
SgScopeStatement scope 
)

Function to delete AST subtree's nodes only, users must take care of any dangling pointers, symbols or types that result.

ROSE_DLL_API SgVariableSymbol* SageInterface::appendArg ( SgFunctionParameterList ,
SgInitializedName  
)

Append an argument to SgFunctionParameterList, transparently set parent,scope, and symbols for arguments when possible.

We recommend to build SgFunctionParameterList before building a function declaration However, it is still allowed to append new arguments for existing function declarations.

Todo:
function type , function symbol also need attention.

Referenced by sg::_append().

ROSE_DLL_API SgVariableSymbol* SageInterface::prependArg ( SgFunctionParameterList ,
SgInitializedName  
)

Prepend an argument to SgFunctionParameterList.

ROSE_DLL_API void SageInterface::appendExpression ( SgExprListExp ,
SgExpression  
)

Append an expression to a SgExprListExp, set the parent pointer also.

Referenced by sg::_append().

ROSE_DLL_API void SageInterface::appendExpressionList ( SgExprListExp ,
const std::vector< SgExpression * > &   
)

Append an expression list to a SgExprListExp, set the parent pointers also.

template<class actualFunction >
ROSE_DLL_API void SageInterface::setParameterList ( actualFunction *  func,
SgFunctionParameterList paralist 
)

Set parameter list for a function declaration, considering existing parameter list etc.

Definition at line 1684 of file sageInterface.h.

References SgFunctionParameterList::get_args(), SgNode::get_parent(), and SgNode::set_parent().

template<class actualFunction >
void SageInterface::setParameterList ( actualFunction *  func,
SgFunctionParameterList paralist 
)

Set parameter list for a function declaration, considering existing parameter list etc.

Definition at line 1684 of file sageInterface.h.

References SgFunctionParameterList::get_args(), SgNode::get_parent(), and SgNode::set_parent().

ROSE_DLL_API void SageInterface::setPragma ( SgPragmaDeclaration decl,
SgPragma pragma 
)

Set a pragma of a pragma declaration. handle memory release for preexisting pragma, and set parent pointer.

ROSE_DLL_API void SageInterface::replaceExpression ( SgExpression oldExp,
SgExpression newExp,
bool  keepOldExp = false 
)

Replace an expression with another, used for variable reference substitution and others. the old expression can be deleted (default case) or kept.

ROSE_DLL_API void SageInterface::replaceExpressionWithStatement ( SgExpression from,
SageInterface::StatementGenerator to 
)

Replace a given expression with a list of statements produced by a generator.

ROSE_DLL_API void SageInterface::replaceSubexpressionWithStatement ( SgExpression from,
SageInterface::StatementGenerator to 
)

Similar to replaceExpressionWithStatement, but with more restrictions.

Assumptions: from is not within the test of a loop or ifStmt, not currently traversing from or the statement it is in

ROSE_DLL_API void SageInterface::setOperand ( SgExpression target,
SgExpression operand 
)

Set operands for expressions with single operand, such as unary expressions. handle file info, lvalue, pointer downcasting, parent pointer etc.

ROSE_DLL_API void SageInterface::setLhsOperand ( SgExpression target,
SgExpression lhs 
)

set left hand operand for binary expressions, transparently downcasting target expressions when necessary

ROSE_DLL_API void SageInterface::setRhsOperand ( SgExpression target,
SgExpression rhs 
)

set left hand operand for binary expression

ROSE_DLL_API void SageInterface::removeAllOriginalExpressionTrees ( SgNode top)

Set original expression trees to NULL for SgValueExp or SgCastExp expressions, so you can change the value and have it unparsed correctly.

ROSE_DLL_API void SageInterface::moveToSubdirectory ( std::string  directoryName,
SgFile file 
)

Move file to be generated in a subdirectory (will be generated by the unparser).

ROSE_DLL_API SgStatement* SageInterface::findSurroundingStatementFromSameFile ( SgStatement targetStmt,
bool &  surroundingStatementPreceedsTargetStatement 
)

Supporting function to comment relocation in insertStatement() and removeStatement().

ROSE_DLL_API void SageInterface::moveCommentsToNewStatement ( SgStatement sourceStatement,
const std::vector< int > &  indexList,
SgStatement targetStatement,
bool  surroundingStatementPreceedsTargetStatement 
)

Relocate comments and CPP directives from one statement to another.

ROSE_DLL_API int SageInterface::fixVariableReferences ( SgNode root)

Connect variable reference to the right variable symbols when feasible, return the number of references being fixed.

In AST translation, it is possible to build a variable reference before the variable is being declared. buildVarRefExp() will use fake initialized name and symbol as placeholders to get the work done. Users should call fixVariableReference() when AST is complete and all variable declarations are in place.

void SageInterface::fixVariableDeclaration ( SgVariableDeclaration varDecl,
SgScopeStatement scope 
)

Patch up symbol, scope, and parent information when a SgVariableDeclaration's scope is known.

It is possible to build a variable declaration without knowing its scope information during bottom-up construction of AST, though top-down construction is recommended in general. In this case, we have to patch up symbol table, scope and parent information when the scope is known. This function is usually used internally within appendStatment(), insertStatement().

void SageInterface::fixStructDeclaration ( SgClassDeclaration structDecl,
SgScopeStatement scope 
)

Fix symbols, parent and scope pointers. Used internally within appendStatment(), insertStatement() etc when a struct declaration was built without knowing its target scope.

void SageInterface::fixClassDeclaration ( SgClassDeclaration classDecl,
SgScopeStatement scope 
)

Fix symbols, parent and scope pointers. Used internally within appendStatment(), insertStatement() etc when a class declaration was built without knowing its target scope.

void SageInterface::fixNamespaceDeclaration ( SgNamespaceDeclarationStatement structDecl,
SgScopeStatement scope 
)

Fix symbols, parent and scope pointers. Used internally within appendStatment(), insertStatement() etc when a namespace declaration was built without knowing its target scope.

void SageInterface::fixLabelStatement ( SgLabelStatement label_stmt,
SgScopeStatement scope 
)

Fix symbol table for SgLabelStatement. Used Internally when the label is built without knowing its target scope. Both parameters cannot be NULL.

void SageInterface::setFortranNumericLabel ( SgStatement stmt,
int  label_value 
)

Set a numerical label for a Fortran statement. The statement should have a enclosing function definition already. SgLabelSymbol and SgLabelRefExp are created transparently as needed.

int SageInterface::suggestNextNumericLabel ( SgFunctionDefinition func_def)

Suggest next usable (non-conflicting) numeric label value for a Fortran function definition scope.

void SageInterface::fixFunctionDeclaration ( SgFunctionDeclaration stmt,
SgScopeStatement scope 
)

Fix the symbol table and set scope (only if scope in declaration is not already set).

void SageInterface::fixTemplateDeclaration ( SgTemplateDeclaration stmt,
SgScopeStatement scope 
)

Fix the symbol table and set scope (only if scope in declaration is not already set).

void SageInterface::fixStatement ( SgStatement stmt,
SgScopeStatement scope 
)

A wrapper containing fixes (fixVariableDeclaration(),fixStructDeclaration(), fixLabelStatement(), etc) for all kinds statements. Should be used before attaching the statement into AST.

void SageInterface::updateDefiningNondefiningLinks ( SgFunctionDeclaration func,
SgScopeStatement scope 
)

Update defining and nondefining links due to a newly introduced function declaration. Should be used after inserting the function into a scope.

This function not only set the defining and nondefining links of the newly introduced function declaration inside a scope, but also update other same function declarations' links accordingly if there are any. Assumption: The function has already inserted/appended/prepended into the scope before calling this function.

ROSE_DLL_API bool SageInterface::collectReadWriteRefs ( SgStatement stmt,
std::vector< SgNode * > &  readRefs,
std::vector< SgNode * > &  writeRefs,
bool  useCachedDefUse = false 
)

Collect all read and write references within stmt, which can be a function, a scope statement, or a single statement. Note that a reference can be both read and written, like i++.

ROSE_DLL_API bool SageInterface::collectReadWriteVariables ( SgStatement stmt,
std::set< SgInitializedName * > &  readVars,
std::set< SgInitializedName * > &  writeVars 
)

Collect unique variables which are read or written within a statement. Note that a variable can be both read and written. The statement can be either of a function, a scope, or a single line statement.

ROSE_DLL_API void SageInterface::collectReadOnlyVariables ( SgStatement stmt,
std::set< SgInitializedName * > &  readOnlyVars 
)

Collect read only variables within a statement. The statement can be either of a function, a scope, or a single line statement.

ROSE_DLL_API void SageInterface::collectReadOnlySymbols ( SgStatement stmt,
std::set< SgVariableSymbol * > &  readOnlySymbols 
)

Collect read only variable symbols within a statement. The statement can be either of a function, a scope, or a single line statement.

ROSE_DLL_API bool SageInterface::isUseByAddressVariableRef ( SgVarRefExp ref)

Check if a variable reference is used by its address: including &a expression and foo(a) when type2 foo(Type& parameter) in C++.

ROSE_DLL_API void SageInterface::collectUseByAddressVariableRefs ( const SgStatement s,
std::set< SgVarRefExp * > &  varSetB 
)

Collect variable references involving use by address: including &a expression and foo(a) when type2 foo(Type& parameter) in C++.

ROSE_DLL_API LivenessAnalysis* SageInterface::call_liveness_analysis ( SgProject project,
bool  debug = false 
)

Call liveness analysis on an entire project.

ROSE_DLL_API void SageInterface::getLiveVariables ( LivenessAnalysis liv,
SgForStatement loop,
std::set< SgInitializedName * > &  liveIns,
std::set< SgInitializedName * > &  liveOuts 
)

get liveIn and liveOut variables for a for loop from liveness analysis result liv.

ROSE_DLL_API void SageInterface::ReductionRecognition ( SgForStatement loop,
std::set< std::pair< SgInitializedName *, VariantT > > &  results 
)

Recognize and collect reduction variables and operations within a C/C++ loop, following OpenMP 3.0 specification for allowed reduction variable types and operation types.

ROSE_DLL_API void SageInterface::constantFolding ( SgNode r)

Constant folding an AST subtree rooted at 'r' (replacing its children with their constant values, if applicable). Please be advised that constant folding on floating point computation may decrease the accuracy of floating point computations!

It is a wrapper function for ConstantFolding::constantFoldingOptimization(). Note that only r's children are replaced with their corresponding constant values, not the input SgNode r itself. You have to call this upon an expression's parent node if you want to fold the expression.

ROSE_DLL_API int SageInterface::instrumentEndOfFunction ( SgFunctionDeclaration func,
SgStatement s 
)

Instrument(Add a statement, often a function call) into a function right before the return points, handle multiple return statements and return expressions with side effects. Return the number of statements inserted.

Useful when adding a runtime library call to terminate the runtime system right before the end of a program, especially for OpenMP and UPC runtime systems. Return with complex expressions with side effects are rewritten using an additional assignment statement.

ROSE_DLL_API void SageInterface::removeJumpsToNextStatement ( SgNode )

Remove jumps whose label is immediately after the jump. Used to clean up inlined code fragments.

ROSE_DLL_API void SageInterface::removeUnusedLabels ( SgNode top)

Remove labels which are not targets of any goto statements.

ROSE_DLL_API void SageInterface::removeConsecutiveLabels ( SgNode top)

Remove consecutive labels.

ROSE_DLL_API SgAssignInitializer* SageInterface::splitExpression ( SgExpression from,
std::string  newName = "" 
)

Replace an expression with a temporary variable and an assignment statement.

Add a new temporary variable to contain the value of 'from' Change reference to 'from' to use this new variable Assumptions: 'from' is not within the test of a loop or 'if' not currently traversing 'from' or the statement it is in

ROSE_DLL_API void SageInterface::splitExpressionIntoBasicBlock ( SgExpression expr)

Split long expressions into blocks of statements.

ROSE_DLL_API void SageInterface::removeLabeledGotos ( SgNode top)

Remove labeled goto statements.

ROSE_DLL_API void SageInterface::changeBreakStatementsToGotos ( SgStatement loopOrSwitch)

If the given statement contains any break statements in its body, add a new label below the statement and change the breaks into gotos to that new label.

ROSE_DLL_API SgBasicBlock* SageInterface::ensureBasicBlockAsBodyOfFor ( SgForStatement fs)

Check if the body of a 'for' statement is a SgBasicBlock, create one if not.

ROSE_DLL_API SgBasicBlock* SageInterface::ensureBasicBlockAsBodyOfUpcForAll ( SgUpcForAllStatement fs)

Check if the body of a 'upc_forall' statement is a SgBasicBlock, create one if not.

ROSE_DLL_API SgBasicBlock* SageInterface::ensureBasicBlockAsBodyOfWhile ( SgWhileStmt ws)

Check if the body of a 'while' statement is a SgBasicBlock, create one if not.

ROSE_DLL_API SgBasicBlock* SageInterface::ensureBasicBlockAsBodyOfDoWhile ( SgDoWhileStmt ws)

Check if the body of a 'do .. while' statement is a SgBasicBlock, create one if not.

ROSE_DLL_API SgBasicBlock* SageInterface::ensureBasicBlockAsBodyOfSwitch ( SgSwitchStatement ws)

Check if the body of a 'switch' statement is a SgBasicBlock, create one if not.

SgBasicBlock* SageInterface::ensureBasicBlockAsBodyOfCaseOption ( SgCaseOptionStmt cs)

Check if the body of a 'case option' statement is a SgBasicBlock, create one if not.

SgBasicBlock* SageInterface::ensureBasicBlockAsBodyOfDefaultOption ( SgDefaultOptionStmt cs)

Check if the body of a 'default option' statement is a SgBasicBlock, create one if not.

ROSE_DLL_API SgBasicBlock* SageInterface::ensureBasicBlockAsTrueBodyOfIf ( SgIfStmt ifs)

Check if the true body of a 'if' statement is a SgBasicBlock, create one if not.

ROSE_DLL_API SgBasicBlock* SageInterface::ensureBasicBlockAsFalseBodyOfIf ( SgIfStmt ifs)

Check if the false body of a 'if' statement is a SgBasicBlock, create one if not.

ROSE_DLL_API SgBasicBlock* SageInterface::ensureBasicBlockAsBodyOfCatch ( SgCatchOptionStmt cos)

Check if the body of a 'catch' statement is a SgBasicBlock, create one if not.

ROSE_DLL_API SgBasicBlock* SageInterface::ensureBasicBlockAsBodyOfOmpBodyStmt ( SgOmpBodyStatement ompbodyStmt)

Check if the body of a SgOmpBodyStatement is a SgBasicBlock, create one if not.

bool SageInterface::isBodyStatement ( SgStatement s)

Check if a statement is a (true or false) body of a container-like parent, such as For, Upc_forall, Do-while, switch, If, Catch, OmpBodyStmt, etc.

void SageInterface::changeAllBodiesToBlocks ( SgNode top)

Fix up ifs, loops, while, switch, Catch, OmpBodyStatement, etc. to have blocks as body components. It also adds an empty else body to if statements that don't have them.

void SageInterface::changeAllLoopBodiesToBlocks ( SgNode top)

The same as changeAllBodiesToBlocks(SgNode* top). To be phased out.

SgBasicBlock* SageInterface::makeSingleStatementBodyToBlock ( SgStatement singleStmt)

Make a single statement body to be a basic block. Its parent is if, while, catch, or upc_forall etc.

unsigned long long SageInterface::getIntegerConstantValue ( SgValueExp expr)

Get the constant value from a constant integer expression; abort on everything else.

Note that signed long longs are converted to unsigned.

std::vector<SgDeclarationStatement*> SageInterface::getDependentDeclarations ( SgStatement stmt)

Get a statement's dependent declarations which declares the types used in the statement. The returned vector of declaration statements are sorted according to their appearance order in the original AST. Any reference to a class or template class from a namespace will treated as a reference to the enclosing namespace.

SgCommaOpExp* SageInterface::insertBeforeUsingCommaOp ( SgExpression new_exp,
SgExpression anchor_exp 
)

Insert an expression (new_exp )before another expression (anchor_exp) has possible side effects, without changing the original semantics. This is achieved by using a comma operator: (new_exp, anchor_exp). The comma operator is returned.

SgCommaOpExp* SageInterface::insertAfterUsingCommaOp ( SgExpression new_exp,
SgExpression anchor_exp,
SgStatement **  temp_decl = NULL,
SgVarRefExp **  temp_ref = NULL 
)

Insert an expression (new_exp ) after another expression (anchor_exp) has possible side effects, without changing the original semantics. This is done by using two comma operators: type T1; ... ((T1 = anchor_exp, new_exp),T1) )... , where T1 is a temp variable saving the possible side effect of anchor_exp. The top level comma op exp is returned. The reference to T1 in T1 = anchor_exp is saved in temp_ref.

std::pair<SgStatement*, SgInitializedName*> SageInterface::wrapFunction ( SgFunctionDeclaration definingDeclaration,
SgName  newName 
)

moves the body of a function f to a new function f; f's body is replaced with code that forwards the call to f.

Returns
a pair indicating the statement containing the call of f` and an initialized name refering to the temporary variable holding the result of f`. In case f returns void the initialized name is NULL.
Parameters
definingDeclarationthe defining function declaration of f
newNamethe name of function f`

f's new body becomes { f(...); } and { int res = f(...); return res; } for functions returning void and a value, respectively. two function declarations are inserted in f's enclosing scope

result_type f`(...); <--- (1)
result_type f (...) { forward call to f` }
result_type f`(...) { original code } <--- (2)

Calls to f are not updated, thus in the transformed code all calls will continue calling f (this is also true for recursive function calls from within the body of f`). After the function has created the wrapper, definingDeclaration becomes the wrapper function The definition of fis the next entry in the statement list; the forward declaration of f is the previous entry in the statement list.

Precondition
definingDeclaration must be a defining declaration of a free standing function. typeid(SgFunctionDeclaration) == typeid(definingDeclaration) i.e., this function is NOT implemented for class member functions, template functions, procedures, etc.

Referenced by wrapFunction().

template<class NameGen >
std::pair<SgStatement*, SgInitializedName*> SageInterface::wrapFunction ( SgFunctionDeclaration definingDeclaration,
NameGen  nameGen 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Template Parameters
NameGenfunctor that generates a new name based on the old name. interface: SgName nameGen(const SgName&)
Parameters
nameGenname generator see wrapFunction for details

Definition at line 2007 of file sageInterface.h.

References SgFunctionDeclaration::get_name(), and wrapFunction().

SgInitializedName& SageInterface::getFirstVariable ( SgVariableDeclaration vardecl)

convenience function that returns the first initialized name in a list of variable declarations.

bool SageInterface::hasTemplateSyntax ( const SgName name)
std::set<unsigned int> SageInterface::collectSourceSequenceNumbers ( SgNode astNode)
bool SageInterface::HasNoThrowAssign ( const SgType *const  inputType)
bool SageInterface::HasNoThrowCopy ( const SgType *const  inputType)
bool SageInterface::HasNoThrowConstructor ( const SgType *const  inputType)
bool SageInterface::HasTrivialAssign ( const SgType *const  inputType)
bool SageInterface::HasTrivialCopy ( const SgType *const  inputType)
bool SageInterface::HasTrivialConstructor ( const SgType *const  inputType)
bool SageInterface::HasTrivialDestructor ( const SgType *const  inputType)
bool SageInterface::HasVirtualDestructor ( const SgType *const  inputType)
bool SageInterface::IsBaseOf ( const SgType *const  inputBaseType,
const SgType *const  inputDerivedType 
)
bool SageInterface::IsAbstract ( const SgType *const  inputType)
bool SageInterface::IsClass ( const SgType *const  inputType)
bool SageInterface::IsEmpty ( const SgType *const  inputType)
bool SageInterface::IsEnum ( const SgType *const  inputType)
bool SageInterface::IsPod ( const SgType *const  inputType)
bool SageInterface::IsPolymorphic ( const SgType *const  inputType)
bool SageInterface::IsStandardLayout ( const SgType *const  inputType)
bool SageInterface::IsLiteralType ( const SgType *const  inputType)
bool SageInterface::IsTrivial ( const SgType *const  inputType)
bool SageInterface::IsUnion ( const SgType *const  inputType)
SgType* SageInterface::UnderlyingType ( SgType type)
void SageInterface::supportForInitializedNameLists ( SgScopeStatement scope,
SgInitializedNamePtrList variableList 
)
bool SageInterface::isStructurallyEquivalentAST ( SgNode tree1,
SgNode tree2 
)
std::string SageInterface::getTempDirectory ( SgProject project)
void SageInterface::destroyTempDirectory ( std::string  )
SgFile* SageInterface::processFile ( SgProject ,
std::string  ,
bool  unparse = false 
)
std::string SageInterface::preprocessPackage ( SgProject ,
std::string   
)
std::string SageInterface::preprocessImport ( SgProject ,
std::string   
)
SgFile* SageInterface::preprocessCompilationUnit ( SgProject ,
std::string  ,
std::string  ,
bool  unparse = true 
)
SgClassDefinition* SageInterface::findJavaPackage ( SgScopeStatement ,
std::string   
)
SgClassDefinition* SageInterface::findOrInsertJavaPackage ( SgProject ,
std::string  ,
bool  create_directory = false 
)
SgClassDeclaration* SageInterface::findOrImportJavaClass ( SgProject ,
SgClassDefinition package_definition,
std::string   
)
SgClassDeclaration* SageInterface::findOrImportJavaClass ( SgProject ,
std::string  ,
std::string   
)
SgClassDeclaration* SageInterface::findOrImportJavaClass ( SgProject ,
SgClassType  
)
SgMemberFunctionDeclaration* SageInterface::findJavaMain ( SgClassDefinition )
SgMemberFunctionDeclaration* SageInterface::findJavaMain ( SgClassType )
void SageInterface::addComment ( SgAsmStatement stmt,
const std::string &  input_string 
)
SgAsmElfSection* SageInterface::getSection ( SgProject project,
const std::string &  name 
)
SgAsmElfSection* SageInterface::getSection ( SgProject project,
size_t  ptr 
)
SgAsmFunction* SageInterface::getAsmFunction ( SgAsmInstruction asmInstruction)

Traverses AST backwards up the tree along the "parent" edges to the SgAsmFunction.

SgAsmBlock* SageInterface::getAsmBlock ( SgAsmInstruction asmInstruction)

Traverses AST backwards up the tree along the "parent" edges to the SgAsmBlock.

SgAsmInterpretation* SageInterface::getAsmInterpretation ( SgAsmNode asmNode)

Traverses AST backwards up the tree along the "parent" edges to the SgAsmInterpretation.

std::string SageInterface::generateUniqueName ( size_t  value,
std::map< size_t, int > &  usedOffsets,
size_t &  counter 
)
size_t SageInterface::get_value ( SgAsmValueExpression asmValueExpression)

Referenced by SgAsmElfSymbol::encode().

std::string SageInterface::get_valueString ( SgAsmValueExpression asmValueExpression)
bool SageInterface::isMovInstruction ( SgAsmInstruction asmInstruction)
bool SageInterface::isInstructionKind ( SgAsmInstruction asmInstruction,
X86InstructionKind  instuctionKind 
)
bool SageInterface::equivalenceTest ( SgNode x,
SgNode y 
)
std::vector<SgNode*> SageInterface::flattenAST ( SgNode node)
std::vector<SgNode*> SageInterface::matchAST ( SgNode node,
std::vector< SgNode * > &  listOfNodes,
EquivalenceTestFunctionType  equivalenceTest 
)
bool SageInterface::isNOP ( SgAsmInstruction asmInstruction)

Test an instruction for if it has no side-effect to the state (is so then it is a NOP). This is a more general test than if it is equivelent to the NOP memonic instruction.

bool SageInterface::isNOP ( const std::vector< SgAsmInstruction * > &  asmInstructionList)

Test a sequence of instructions for it they (as a set) have no side-effects to the state (is so then it is a NOP sequence).

std::vector<std::vector<SgAsmInstruction*> > SageInterface::find_NOP_sequences ( SgAsmBlock asmBlock)

find sequences of NOP instructions in a SgAsmBlock

void SageInterface::insertInstruction ( SgAsmInstruction targetInstruction,
SgAsmInstruction newInstruction,
bool  insertBefore 
)

Support for insertion of instruction relative to a target instruction.

void SageInterface::insertInstructionBefore ( SgAsmInstruction targetInstruction,
SgAsmInstruction newInstruction 
)

Insert a instruction before a target instruction.

void SageInterface::removeInstruction ( SgAsmStatement instruction)

Remove a instruction.

Variable Documentation

ROSE_DLL_API int SageInterface::gensym_counter

An internal counter for generating unique SgName.