ROSE 0.11.145.192
|
Functions that are useful when operating on the AST.
The Sage III IR design attempts to be minimalist. Thus additional functionality is intended to be presented using separate higher level interfaces which work with the IR. This namespace collects functions that operate on the IR and support numerous types of operations that are common to general analysis and transformation of the AST.
Namespaces | |
namespace | Ada |
Contains Ada-specific functionality. | |
Classes | |
class | AndOpGenerator |
class | ConditionalExpGenerator |
struct | const_int_expr_t |
class | DeclarationSets |
struct | DeferredTransformation |
class | OrOpGenerator |
class | OutputLocalSymbolTables |
struct | PreprocessingInfoData |
class | StatementGenerator |
Interface for creating a statement whose computation writes its answer into a given variable. More... | |
struct | Transformation_Record |
class | UniqueNameAttribute |
A persistent attribute to represent a unique name for an expression. More... | |
Typedefs | |
typedef bool(* | EquivalenceTestFunctionType) (SgNode *x, SgNode *y) |
Functions | |
DeclarationSets * | buildDeclarationSets (SgNode *) |
void | addMessageStatement (SgStatement *stmt, std::string message) |
Function to add "C" style comment to statement. | |
void | addComment (SgAsmStatement *stmt, const std::string &input_string) |
SgAsmElfSection * | getSection (SgProject *project, const std::string &name) |
SgAsmElfSection * | getSection (SgProject *project, size_t ptr) |
SgAsmFunction * | getAsmFunction (SgAsmInstruction *asmInstruction) |
Traverses AST backwards up the tree along the "parent" edges to the SgAsmFunction. | |
SgAsmBlock * | getAsmBlock (SgAsmInstruction *asmInstruction) |
Traverses AST backwards up the tree along the "parent" edges to the SgAsmBlock. | |
SgAsmInterpretation * | getAsmInterpretation (SgAsmNode *asmNode) |
Traverses AST backwards up the tree along the "parent" edges to the SgAsmInterpretation. | |
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, Rose::BinaryAnalysis::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. | |
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). | |
std::vector< std::vector< SgAsmInstruction * > > | find_NOP_sequences (SgAsmBlock *asmBlock) |
find sequences of NOP instructions in a SgAsmBlock | |
void | insertInstruction (SgAsmInstruction *targetInstruction, SgAsmInstruction *newInstruction, bool insertBefore) |
Support for insertion of instruction relative to a target instruction. | |
void | insertInstructionBefore (SgAsmInstruction *targetInstruction, SgAsmInstruction *newInstruction) |
Insert a instruction before a target instruction. | |
void | removeInstruction (SgAsmStatement *instruction) |
Remove a instruction. | |
template<class T > | |
void | setSourcePositionToDefault (T *node) |
Source File Position | |
set Sg_File_Info for a SgNode | |
ROSE_DLL_API void | setOneSourcePositionForTransformation (SgNode *node) |
Set current node's source position as transformation generated. | |
ROSE_DLL_API void | setSourcePosition (SgNode *node) |
Set the source code positon for the current (input) node. | |
ROSE_DLL_API void | setSourcePositionAtRootAndAllChildren (SgNode *root) |
Set the source code positon for the subtree (including the root). | |
void | setSourcePositionAsTransformation (SgNode *node) |
DQ (5/1/2012): New function with improved name. | |
void | setSourcePositionPointersToNull (SgNode *node) |
Set the source code positon for the current (input) node. | |
ROSE_DLL_API void | setOneSourcePositionNull (SgNode *node) |
Set current node's source position as NULL. | |
ROSE_DLL_API void | setSourcePositionForTransformation (SgNode *root) |
Recursively set source position info(Sg_File_Info) as transformation generated. | |
ROSE_DLL_API bool | insideSystemHeader (SgLocatedNode *node) |
Set source position info(Sg_File_Info) as transformation generated for all SgNodes in memory pool. | |
ROSE_DLL_API bool | insideHeader (SgLocatedNode *node) |
Check if a node is from a header file. | |
Symbol tables | |
utility functions for symbol tables | |
ROSE_DLL_API SgSymbol * | lookupSymbolInParentScopesIgnoringAliasSymbols (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 SgSymbol * | 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 SgVariableSymbol * | 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 SgFunctionSymbol * | 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 * | 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 SgFunctionSymbol * | lookupTemplateFunctionSymbolInParentScopes (const SgName &functionName, SgFunctionType *ftype, SgTemplateParameterPtrList *tplparams, 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 SgFunctionSymbol * | lookupTemplateMemberFunctionSymbolInParentScopes (const SgName &functionName, SgFunctionType *ftype, SgTemplateParameterPtrList *tplparams, 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 SgTemplateVariableSymbol * | lookupTemplateVariableSymbolInParentScopes (const SgName &name, SgTemplateParameterPtrList *tplparams, SgTemplateArgumentPtrList *tplargs, 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 SgClassSymbol * | 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 * | 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 SgNonrealSymbol * | lookupNonrealSymbolInParentScopes (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 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. | |
ROSE_DLL_API SgEnumSymbol * | 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 * | 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 | set_name (SgInitializedName *initializedNameNode, SgName new_name) |
set_name of symbol in symbol table. | |
void | outputGlobalFunctionTypeSymbolTable () |
Output function type symbols in global function type symbol table. | |
ROSE_DLL_API void | outputLocalSymbolTables (SgNode *node) |
Output the local symbol tables. | |
void | rebuildSymbolTable (SgScopeStatement *scope) |
Regenerate the symbol table. | |
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. | |
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. | |
Class utilities | |
ROSE_DLL_API SgMemberFunctionDeclaration * | getDefaultDestructor (SgClassDeclaration *classDeclaration) |
Get the default destructor from the class declaration. | |
ROSE_DLL_API SgMemberFunctionDeclaration * | getDefaultConstructor (SgClassDeclaration *classDeclaration) |
Get the default constructor from the class declaration. | |
ROSE_DLL_API bool | templateDefinitionIsInClass (SgTemplateInstantiationMemberFunctionDecl *memberFunctionDeclaration) |
Return true if template definition is in the class, false if outside of class. | |
ROSE_DLL_API SgTemplateInstantiationMemberFunctionDecl * | buildForwardFunctionDeclaration (SgTemplateInstantiationMemberFunctionDecl *memberFunctionInstantiation) |
Generate a non-defining (forward) declaration from a defining function declaration. | |
ROSE_DLL_API bool | isStructDeclaration (SgNode *node) |
Check if a SgNode is a declaration for a structure. | |
ROSE_DLL_API bool | isUnionDeclaration (SgNode *node) |
Check if a SgNode is a declaration for a union. | |
ROSE_DLL_API bool | addDefaultConstructorIfRequired (SgClassType *classType, int physical_file_id=Sg_File_Info::TRANSFORMATION_FILE_ID) |
Get the default destructor from the class declaration. | |
Misc. | |
Not sure the classifications right now | |
void | recursivePrintCurrentAndParent (SgNode *n) |
Recursively print current and parent nodes. used within gdb to probe the context of a node. | |
void | saveToPDF (SgNode *node, std::string filename) |
Save AST into a pdf file. Start from a node to find its enclosing file node. The entire file's AST will be saved into a pdf. | |
void | saveToPDF (SgNode *node) |
Recursively print current and parent nodes. used within gdb to probe the context of a node. | |
void | printAST (SgNode *node) |
Pretty print AST horizontally, output to std output. | |
void | printAST (SgNode *node, const char *filename) |
Pretty print AST horizontally, output to a specified file, a simpiler interface than printAST2TextFile() | |
void | printAST2TextFile (SgNode *node, const char *filename, bool printType=true) |
Pretty print AST horizontally, output to a specified text file. If printType is set to false, don't print out type info. | |
void | printAST2TextFile (SgNode *node, std::string filename, bool printType=true) |
Pretty print AST horizontally, output to a specified text file. If printType is set to false, don't print out types info. | |
void | 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 | extractPragmaKeyword (const SgPragmaDeclaration *) |
Extract a SgPragmaDeclaration's leading keyword . For example "#pragma omp parallel" has a keyword of "omp". | |
ROSE_DLL_API bool | isOmpStatement (SgNode *) |
Check if a node is SgOmp*Statement. | |
bool | isOverloaded (SgFunctionDeclaration *functionDeclaration) |
Return true if function is overloaded. | |
void | initializeIfStmt (SgIfStmt *ifstmt, SgStatement *conditional, SgStatement *true_body, SgStatement *false_body) |
Support function used for variable declarations in conditionals. | |
void | initializeSwitchStatement (SgSwitchStatement *switchStatement, SgStatement *item_selector, SgStatement *body) |
Support function used for variable declarations in conditionals. | |
void | initializeWhileStatement (SgWhileStmt *whileStatement, SgStatement *condition, SgStatement *body, SgStatement *else_body) |
Support function used for variable declarations in conditionals. | |
void | annotateExpressionsWithUniqueNames (SgProject *project) |
Generate unique names for expressions and attach the names as persistent attributes ("UniqueNameAttribute") | |
ROSE_DLL_API bool | isMain (const SgNode *node) |
Check if a SgNode is a main() function declaration. | |
std::string | generateUniqueName (const SgNode *node, bool ignoreDifferenceBetweenDefiningAndNondefiningDeclarations) |
Generate unique name from C and C++ constructs. The name may contain space. | |
std::string | generateUniqueVariableName (SgScopeStatement *scope, std::string baseName="temp") |
Generate a name like temp# that is unique in the current scope and any parent and children scopes. | |
std::string | declarationPositionString (const SgDeclarationStatement *declaration) |
Generate a unique string from the source file position information. | |
ROSE_DLL_API std::string | generateProjectName (const SgProject *project, bool supressSuffix=false) |
Added mechanism to generate project name from list of file names. | |
SgFunctionDeclaration * | getDeclarationOfNamedFunction (SgExpression *func) |
Given a SgExpression that represents a named function (or bound member function), return the mentioned function. | |
SgExpression * | forallMaskExpression (SgForAllStatement *stmt) |
Get the mask expression from the header of a SgForAllStatement. | |
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. | |
void | clearMangledNameCache (SgGlobal *globalScope) |
Support for faster mangled name generation (caching avoids recomputation). | |
void | resetMangledNameCache (SgGlobal *globalScope) |
Recursively print current and parent nodes. used within gdb to probe the context of a node. | |
std::string | getMangledNameFromCache (SgNode *astNode) |
Recursively print current and parent nodes. used within gdb to probe the context of a node. | |
std::string | addMangledNameToCache (SgNode *astNode, const std::string &mangledName) |
Recursively print current and parent nodes. used within gdb to probe the context of a node. | |
SgDeclarationStatement * | getNonInstantiatonDeclarationForClass (SgTemplateInstantiationMemberFunctionDecl *memberFunctionInstantiation) |
Recursively print current and parent nodes. used within gdb to probe the context of a node. | |
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 | |
bool | declarationPreceedsDefinition (SgDeclarationStatement *nonDefiningDeclaration, SgDeclarationStatement *definingDeclaration) |
Check if a defining declaration comes before of after the non-defining declaration. | |
bool | functionCallExpressionPreceedsDeclarationWhichAssociatesScope (SgFunctionCallExp *functionCall) |
Recursively print current and parent nodes. used within gdb to probe the context of a node. | |
ROSE_DLL_API std::vector< SgNode * > | astIntersection (SgNode *original, SgNode *copy, SgCopyHelp *help=NULL) |
Compute the intersection set for two ASTs. | |
ROSE_DLL_API SgNode * | deepCopyNode (const SgNode *subtree) |
Deep copy an arbitrary subtree. | |
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);. | |
ROSE_DLL_API SgExpression * | copyExpression (SgExpression *e) |
Deep copy an expression. | |
ROSE_DLL_API SgStatement * | copyStatement (SgStatement *s) |
Deep copy a statement. | |
ROSE_DLL_API SgVariableSymbol * | getFirstVarSym (SgVariableDeclaration *decl) |
Get the variable symbol for the first initialized name of a declaration stmt. | |
ROSE_DLL_API SgInitializedName * | getFirstInitializedName (SgVariableDeclaration *decl) |
Get the first initialized name of a declaration statement. | |
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. | |
ROSE_DLL_API bool | isConstantTrue (SgExpression *e) |
Check if a bool or int constant expression evaluates to be a true value. | |
ROSE_DLL_API bool | isConstantFalse (SgExpression *e) |
Check if a bool or int constant expression evaluates to be a false value. | |
ROSE_DLL_API bool | isCallToParticularFunction (SgFunctionDeclaration *decl, SgExpression *e) |
Recursively print current and parent nodes. used within gdb to probe the context of a node. | |
ROSE_DLL_API bool | isCallToParticularFunction (const std::string &qualifiedName, size_t arity, SgExpression *e) |
Recursively print current and parent nodes. used within gdb to probe the context of a node. | |
bool ROSE_DLL_API | isStatic (SgDeclarationStatement *stmt) |
Check if a declaration has a "static' modifier. | |
ROSE_DLL_API void | setStatic (SgDeclarationStatement *stmt) |
Set a declaration as static. | |
ROSE_DLL_API bool | isExtern (SgDeclarationStatement *stmt) |
Check if a declaration has an "extern" modifier. | |
ROSE_DLL_API void | setExtern (SgDeclarationStatement *stmt) |
Set a declaration as extern. | |
ROSE_DLL_API bool ROSE_DLL_API | isMutable (SgInitializedName *name) |
True if an SgInitializedName is "mutable' (has storage modifier set) | |
ROSE_DLL_API bool ROSE_DLL_API | isJovialOutParam (SgInitializedName *name) |
True if a parameter name is a Jovial output parameter. | |
ROSE_DLL_API std::vector< SgInitializedName * > | getInParameters (const SgInitializedNamePtrList ¶ms) |
Get a vector of Jovial input parameters from the function parameter list (may work for Fortran in the future) | |
ROSE_DLL_API std::vector< SgInitializedName * > | getOutParameters (const SgInitializedNamePtrList ¶ms) |
Get a vector of Jovial output parameters from the function parameter list (may work for Fortran in the future) | |
ROSE_DLL_API 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) | |
ROSE_DLL_API SgInitializedName * | convertRefToInitializedName (SgNode *current, bool coarseGrain=true) |
Variable references can be introduced by SgVarRef, SgPntrArrRefExp, SgInitializedName, SgMemberFunctionRef etc. For Dot and Arrow Expressions, their lhs is used to obtain SgInitializedName (coarse grain) by default. Otherwise, fine-grain rhs is used. | |
ROSE_DLL_API AbstractHandle::abstract_handle * | buildAbstractHandle (SgNode *) |
Build an abstract handle from an AST node, reuse previously built handle when possible. | |
ROSE_DLL_API SgNode * | getSgNodeFromAbstractHandleString (const std::string &input_string) |
Obtain a matching SgNode from an abstract handle string. | |
ROSE_DLL_API void | dumpInfo (SgNode *node, std::string desc="") |
Dump information about a SgNode for debugging. | |
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. | |
ROSE_DLL_API 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. | |
ROSE_DLL_API bool | isPrefixOperatorName (const SgName &functionName) |
Check for proper names of possible prefix operators (used in isPrefixOperator()). | |
ROSE_DLL_API bool | isPostfixOperator (SgExpression *exp) |
Is an overloaded operator a postfix operator. (e.g. ). | |
ROSE_DLL_API 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[]()). | |
ROSE_DLL_API SgStatement * | lastStatementOfScopeWithTokenInfo (SgScopeStatement *scope, std::map< SgNode *, TokenStreamSequenceToNodeMapping * > &tokenStreamSequenceMap) |
Used to support token unparsing (when the output the trailing token sequence). | |
ROSE_DLL_API void | checkAccessPermissions (SgNode *) |
Recursively print current and parent nodes. used within gdb to probe the context of a node. | |
ROSE_DLL_API void | checkSymbolTables (SgNode *) |
Recursively print current and parent nodes. used within gdb to probe the context of a node. | |
ROSE_DLL_API void | markSubtreeToBeUnparsed (SgNode *root, int physical_file_id) |
Recursively print current and parent nodes. used within gdb to probe the context of a node. | |
ROSE_DLL_API void | markNodeToBeUnparsed (SgNode *node, int physical_file_id) |
Recursively print current and parent nodes. used within gdb to probe the context of a node. | |
ROSE_DLL_API void | markSubtreeToBeUnparsedTreeTraversal (SgNode *root, int physical_file_id) |
Recursively print current and parent nodes. used within gdb to probe the context of a node. | |
ROSE_DLL_API bool | findFirstSgCastExpMarkedAsTransformation (SgNode *n, const std::string &s) |
Recursively print current and parent nodes. used within gdb to probe the context of a node. | |
AST properties | |
version, language properties of current AST. | |
ROSE_DLL_API bool | is_Ada_language () |
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 () |
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_Jovial_language () |
ROSE_DLL_API bool | is_Jvm_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_OpenCL_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 () |
ROSE_DLL_API bool | is_language_case_insensitive () |
ROSE_DLL_API bool | language_may_contain_nondeclarations_in_scope () |
Scope | |
void | resetScopeNumbers (SgFunctionDefinition *functionDeclaration) |
Assigns unique numbers to each SgScopeStatement of a function. | |
void | clearScopeNumbers (SgFunctionDefinition *functionDefinition) |
Clears the cache of scope,integer pairs for the input function. | |
SgNamespaceDefinitionStatement * | enclosingNamespaceScope (SgDeclarationStatement *declaration) |
Find the enclosing namespace of a declaration. | |
bool | isPrototypeInScope (SgScopeStatement *scope, SgFunctionDeclaration *functionDeclaration, SgDeclarationStatement *startingAtDeclaration) |
Assigns unique numbers to each SgScopeStatement of a function. | |
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) | |
Preprocessing Information | |
#if-#else-#end, comments, #include, etc | |
void | dumpPreprocInfo (SgLocatedNode *locatedNode) |
Dumps a located node's preprocessing information. | |
ROSE_DLL_API PreprocessingInfo * | findHeader (SgSourceFile *source_file, const std::string &header_file_name, bool isSystemHeader) |
Find the preprocessingInfo node representing #include <header.h> or #include "header.h" within a source file. Return NULL if not found. | |
ROSE_DLL_API PreprocessingInfo * | insertHeader (SgSourceFile *source_file, const std::string &header_file_name, bool isSystemHeader, bool asLastHeader) |
Insert #include "filename" or #include <filename> (system header) onto the global scope of a source file, add to be the last #include .. by default among existing headers, Or as the first header. Recommended for use. | |
ROSE_DLL_API void | insertHeader (SgStatement *stmt, PreprocessingInfo *newheader, bool asLastHeader) |
Insert a new header right before stmt, if there are existing headers attached to stmt, insert it as the last or first header as specified by asLastHeader. | |
ROSE_DLL_API PreprocessingInfo * | insertHeader (SgSourceFile *source_file, const std::string &header_file_name, bool isSystemHeader=false, PreprocessingInfo::RelativePositionType position=PreprocessingInfo::before) |
Insert #include "filename" or #include <filename> (system header) onto the global scope of a source file. | |
ROSE_DLL_API PreprocessingInfo * | 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 | 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 | 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 | 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 | 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 * | 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 | 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. | |
PreprocessingInfo * | attachComment (SgSourceFile *source_file, const std::string &content, PreprocessingInfo::DirectiveType directive_type=PreprocessingInfo::C_StyleComment, PreprocessingInfo::RelativePositionType position=PreprocessingInfo::before) |
Build and attach comment onto the global scope of a source file. | |
ROSE_DLL_API PreprocessingInfo * | attachComment (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. | |
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. | |
void | guardNode (SgLocatedNode *target, std::string guard) |
Add preproccessor guard around a given node. | |
ROSE_DLL_API int | moveUpInnerDanglingIfEndifDirective (SgLocatedNode *lnode) |
Extract sequences like " #endif #endif ... #if | #ifdef| #ifndef" buried inside subtree of lnode. | |
ROSE_DLL_API int | eraseNullPreprocessingInfo (SgLocatedNode *lnode) |
Dumps a located node's preprocessing information. | |
ROSE_DLL_API void | preOrderCollectPreprocessingInfo (SgNode *current, std::vector< PreprocessingInfo * > &infoList, int depth) |
Dumps a located node's preprocessing information. | |
Data types | |
Set the source position of SgLocatedNode to Sg_File_Info::generateDefaultFileInfo(). These nodes WILL be unparsed. Not for transformation usage. | |
SgType * | getBoolType (SgNode *n) |
Get the right bool type according to C or C++ language input. | |
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. | |
ROSE_DLL_API SgType * | getFirstVarType (SgVariableDeclaration *decl) |
Get the data type of the first initialized name of a declaration statement. | |
ROSE_DLL_API bool | isDefaultConstructible (SgType *type) |
Is a type default constructible? This may not quite work properly. | |
ROSE_DLL_API bool | isCopyConstructible (SgType *type) |
Is a type copy constructible? This may not quite work properly. | |
ROSE_DLL_API bool | isAssignable (SgType *type) |
Is a type assignable? This may not quite work properly. | |
ROSE_DLL_API bool | isPureVirtualClass (SgType *type, const ClassHierarchyWrapper &classHierarchy) |
Check if a class type is a pure virtual class. | |
ROSE_DLL_API bool | hasTrivialDestructor (SgType *t) |
Does a type have a trivial (built-in) destructor? | |
ROSE_DLL_API bool | isNonconstReference (SgType *t) |
Is this type a non-constant reference type? (Handles typedefs correctly) | |
ROSE_DLL_API bool | isReferenceType (SgType *t) |
Is this type a const or non-const reference type? (Handles typedefs correctly) | |
ROSE_DLL_API bool | isPointerType (SgType *t) |
Is this type a pointer type? (Handles typedefs correctly) | |
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. | |
ROSE_DLL_API bool | isConstType (SgType *t) |
Is this a const type? | |
SgType * | removeConst (SgType *t) |
Remove const (if present) from a type. stripType() cannot do this because it removes all modifiers. | |
ROSE_DLL_API bool | isVolatileType (SgType *t) |
Is this a volatile type? | |
ROSE_DLL_API bool | isRestrictType (SgType *t) |
Is this a restrict type? | |
ROSE_DLL_API bool | isScalarType (SgType *t) |
Is this a scalar type? | |
ROSE_DLL_API bool | isStructType (SgType *t) |
Check if a type is a struct type (a special SgClassType in ROSE). Typedef and modifier types are not stripped off. Only direct struct type is returned as true. | |
ROSE_DLL_API std::string | mangleType (SgType *type) |
Generate a mangled string for a given type based on Itanium C++ ABI. | |
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. | |
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. | |
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. | |
ROSE_DLL_API int | getDimensionCount (SgType *t) |
Get the number of dimensions of an array type. | |
ROSE_DLL_API SgType * | getArrayElementType (SgType *t) |
Get the element type of an array. It recursively find the base type for multi-dimension array types. | |
ROSE_DLL_API SgType * | getElementType (SgType *t) |
Get the element type of an array, pointer or string, or NULL if not applicable. This function only check one level base type. No recursion. | |
std::vector< SgExpression * > | get_C_array_dimensions (const SgArrayType &arrtype) |
returns the array dimensions in an array as defined for arrtype | |
std::vector< SgExpression * > | get_C_array_dimensions (const SgArrayType &arrtype, const SgVarRefExp &varref) |
returns the array dimensions in an array as defined for arrtype | |
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. | |
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. | |
ROSE_DLL_API int | collectVariableReferencesInArrayTypes (SgLocatedNode *root, Rose_STL_Container< SgNode * > ¤tVarRefList) |
Collect variable references in array types. The default NodeQuery::querySubTree() will miss variables referenced in array type's index list. e.g. double *buffer = new double[numItems] ;. | |
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. | |
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. | |
ROSE_DLL_API bool | isUpcSharedModifierType (SgModifierType *mod_type) |
Check if a modifier type is a UPC shared type. | |
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. | |
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.) | |
ROSE_DLL_API size_t | getUpcSharedBlockSize (SgModifierType *mod_type) |
Get the block size of a UPC shared modifier type. | |
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) | |
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. | |
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. | |
ROSE_DLL_API bool | isUpcArrayWithThreads (SgArrayType *t) |
Is a UPC array with dimension of X*THREADS. | |
ROSE_DLL_API SgType * | 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 SgType * | getAssociatedTypeFromFunctionTypeList (SgExpression *actual_argument_expression) |
Get the type of the associated argument expression from the function type. | |
ROSE_DLL_API bool | templateArgumentEquivalence (SgTemplateArgument *arg1, SgTemplateArgument *arg2) |
Verify that 2 SgTemplateArgument are equivalent (same type, same expression, or same template declaration) | |
ROSE_DLL_API bool | templateArgumentListEquivalence (const SgTemplateArgumentPtrList &list1, const SgTemplateArgumentPtrList &list2) |
Verify that 2 SgTemplateArgumentPtrList are equivalent. | |
ROSE_DLL_API bool | isEquivalentType (const SgType *lhs, const SgType *rhs) |
Test for equivalence of types independent of access permissions (private or protected modes for members of classes). | |
ROSE_DLL_API SgFunctionType * | findFunctionType (SgType *return_type, SgFunctionParameterTypeList *typeList) |
Find the function type matching a function signature plus a given return type. | |
ROSE_DLL_API bool | isEquivalentFunctionType (const SgFunctionType *lhs, const SgFunctionType *rhs) |
Test if two types are equivalent SgFunctionType nodes. | |
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. | |
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. | |
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. | |
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. | |
ROSE_DLL_API void | changeContinuesToGotos (SgStatement *stmt, SgLabelStatement *label) |
Change continue statements in a given block of code to gotos to a label. | |
ROSE_DLL_API SgInitializedName * | getLoopIndexVariable (SgNode *loop) |
Return the loop index variable for a for loop. | |
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. | |
ROSE_DLL_API bool | hasMultipleInitStatmentsOrExpressions (SgForStatement *for_loop) |
Check if a for loop uses C99 style initialization statement with multiple expressions like for (int i=0, j=0; ..) or for (i=0,j=0;...) | |
ROSE_DLL_API SgStatement * | getLoopBody (SgScopeStatement *loop) |
Routines to get and set the body of a loop. | |
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. | |
ROSE_DLL_API SgStatement * | 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 | 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 | 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. | |
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. | |
ROSE_DLL_API void | setLoopLowerBound (SgNode *loop, SgExpression *lb) |
Set the lower bound of a loop header for (i=lb; ...) | |
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, ...) | |
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) | |
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. | |
ROSE_DLL_API bool | unnormalizeForLoopInitDeclaration (SgForStatement *loop) |
Undo the normalization of for loop's C99 init declaration. Previous record of normalization is used to ease the reverse transformation. | |
ROSE_DLL_API bool | forLoopNormalization (SgForStatement *loop, bool foldConstant=true) |
Normalize a for loop, return true if successful. | |
ROSE_DLL_API bool | normalizeForLoopTest (SgForStatement *loop) |
Normalize a for loop's test expression i<x is normalized to i<= (x-1) and i>x is normalized to i>= (x+1) | |
ROSE_DLL_API bool | normalizeForLoopIncrement (SgForStatement *loop) |
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. | |
ROSE_DLL_API bool | doLoopNormalization (SgFortranDo *loop) |
Normalize a Fortran Do loop. Make the default increment expression (1) explicit. | |
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. | |
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!). | |
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. | |
SgExprListExp * | 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. | |
bool | getForLoopInformations (SgForStatement *for_loop, SgVariableSymbol *&iterator, SgExpression *&lower_bound, SgExpression *&upper_bound, SgExpression *&stride) |
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. | |
std::vector< SgFile * > | generateFileList () |
Returns STL vector of SgFile IR node pointers. | |
ROSE_DLL_API SgProject * | getProject () |
Get the current SgProject IR Node. | |
SgProject * | getProject (const SgNode *node) |
void | serialize (SgNode *node, std::string &prefix, bool hasRemaining, std::ostringstream &out, std::string &edgeLabel) |
we have two serialize() functions, one for a single node, the other for a list of pointers | |
template<typename T > | |
void | serialize_list (T &plist, std::string T_name, std::string &prefix, bool hasRemaining, std::ostringstream &out, std::string &edgeLabel) |
Query a subtree to get all nodes of a given type, with an appropriate downcast. | |
ROSE_DLL_API SgFunctionDeclaration * | findMain (SgNode *currentNode) |
top-down traversal from current node to find the main() function declaration | |
SgStatement * | findLastDeclarationStatement (SgScopeStatement *scope, bool includePragma=false) |
Find the last declaration statement within a scope (if any). This is often useful to decide where to insert another variable declaration statement. Pragma declarations are not treated as a declaration by default in this context. | |
std::vector< SgVariableSymbol * > | getSymbolsUsedInExpression (SgExpression *expr) |
Find referenced symbols within an expression. | |
std::vector< SgBreakStmt * > | findBreakStmts (SgStatement *code, const std::string &fortranLabel="") |
Find break statements inside a particular statement, stopping at nested loops or switches. | |
std::vector< SgContinueStmt * > | findContinueStmts (SgStatement *code, const std::string &fortranLabel="") |
Find all continue statements inside a particular statement, stopping at nested loops. | |
std::vector< SgGotoStatement * > | findGotoStmts (SgStatement *scope, SgLabelStatement *l) |
Query a subtree to get all nodes of a given type, with an appropriate downcast. | |
std::vector< SgStatement * > | getSwitchCases (SgSwitchStatement *sw) |
Query a subtree to get all nodes of a given type, with an appropriate downcast. | |
void | collectVarRefs (SgLocatedNode *root, std::vector< SgVarRefExp * > &result) |
Collect all variable references in a subtree. | |
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. | |
SgFunctionDeclaration * | 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>. | |
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. | |
ROSE_DLL_API SgSourceFile * | getEnclosingSourceFile (SgNode *n, const bool includingSelf=false) |
Find enclosing source file node. | |
ROSE_DLL_API SgScopeStatement * | getScope (const SgNode *astNode) |
Get the closest scope from astNode. Return astNode if it is already a scope. | |
ROSE_DLL_API SgScopeStatement * | getEnclosingScope (SgNode *n, const bool includingSelf=false) |
Get the enclosing scope from a node n. | |
ROSE_DLL_API SgGlobal * | getGlobalScope (const SgNode *astNode) |
Traverse back through a node's parents to find the enclosing global scope. | |
ROSE_DLL_API bool | hasSameGlobalScope (SgStatement *statement_1, SgStatement *statement_2) |
This is supporting the recognition of functions in header files from two different ASTs. | |
ROSE_DLL_API SgFunctionDefinition * | getEnclosingProcedure (SgNode *n, const bool includingSelf=false) |
Find the function definition. | |
ROSE_DLL_API SgFunctionDefinition * | getEnclosingFunctionDefinition (SgNode *astNode, const bool includingSelf=false) |
Find a node by type using upward traversal. | |
ROSE_DLL_API SgStatement * | getEnclosingStatement (SgNode *n) |
Find the closest enclosing statement, including the given node. | |
ROSE_DLL_API SgSwitchStatement * | findEnclosingSwitch (SgStatement *s) |
Find the closest switch outside a given statement (normally used for case and default statements) | |
ROSE_DLL_API SgOmpClauseBodyStatement * | findEnclosingOmpClauseBodyStatement (SgStatement *s) |
Find enclosing OpenMP clause body statement from s. If s is already one, return it directly. | |
ROSE_DLL_API SgScopeStatement * | 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 * | 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 * | getEnclosingFileNode (SgNode *astNode) |
get the SgFile node from current node | |
ROSE_DLL_API SgInitializer * | getInitializerOfExpression (SgExpression *n) |
Get the initializer containing an expression if it is within an initializer. | |
ROSE_DLL_API SgClassDefinition * | getEnclosingClassDefinition (SgNode *astnode, const bool includingSelf=false) |
Get the closest class definition enclosing the specified AST node,. | |
ROSE_DLL_API SgClassDeclaration * | getEnclosingClassDeclaration (SgNode *astNode) |
Get the closest class declaration enclosing the specified AST node,. | |
ROSE_DLL_API SgExprListExp * | getEnclosingExprListExp (SgNode *astNode, const bool includingSelf=false) |
Get the enclosing SgExprListExp (used as part of function argument index evaluation in subexpressions). | |
ROSE_DLL_API bool | isInSubTree (SgExpression *subtree, SgExpression *exp) |
Find a node by type using upward traversal. | |
ROSE_DLL_API SgFunctionDeclaration * | getFunctionDeclaration (SgFunctionCallExp *functionCallExp) |
Find a node by type using upward traversal. | |
ROSE_DLL_API bool | isDataMemberReference (SgVarRefExp *varRefExp) |
Find a node by type using upward traversal. | |
ROSE_DLL_API bool | isAddressTaken (SgExpression *refExp) |
Find a node by type using upward traversal. | |
ROSE_DLL_API bool | isMemberFunctionMemberReference (SgMemberFunctionRefExp *memberFunctionRefExp) |
Find a node by type using upward traversal. | |
ROSE_DLL_API std::list< SgClassType * > | getClassTypeChainForMemberReference (SgExpression *refExp) |
Find a node by type using upward traversal. | |
ROSE_DLL_API std::set< SgNode * > | getFrontendSpecificNodes () |
Find a node by type using upward traversal. | |
ROSE_DLL_API void | outputSharedNodes (SgNode *node) |
Find a node by type using upward traversal. | |
ROSE_DLL_API void | displayScope (SgScopeStatement *scope) |
Find a node by type using upward traversal. | |
AST Walk and Traversal | |
ROSE_DLL_API SgGlobal * | getFirstGlobalScope (SgProject *project) |
return the first global scope under current project | |
ROSE_DLL_API SgStatement * | getLastStatement (SgScopeStatement *scope) |
get the last statement within a scope, return NULL if it does not exit | |
ROSE_DLL_API SgStatement * | 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 * | findFirstDefiningFunctionDecl (SgScopeStatement *scope) |
Find the first defining function declaration statement in a scope. | |
ROSE_DLL_API SgStatement * | getNextStatement (SgStatement *currentStmt) |
Get next statement within the same scope of current statement. | |
ROSE_DLL_API SgStatement * | getPreviousStatement (SgStatement *currentStmt, bool climbOutScope=true) |
Get previous statement of the current statement. It may return a previous statement of a parent scope by default (climbOutScope is true), otherwise only a previous statement of the same scope is returned. | |
ROSE_DLL_API void | listHeaderFiles (SgIncludeFile *includeFile) |
return path prefix for subtree of include files. | |
ROSE_DLL_API bool | scopeHasStatementsFromSameFile (SgScopeStatement *scope) |
This function supports the token-based unparsing when used with unparsing of header files to know when the scope can be unparsed via it's token stream, even though a statement from a header file may contain a transformation. returns true if there is a statement in the scope that has to be unparsed (is from the same file as the scope). returns false if the scope is empty or contains only statements associated with one or more header files. | |
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. | |
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. | |
ROSE_DLL_API bool | isLastStatement (SgStatement *stmt) |
Check if a statement is the last statement within its closed scope. | |
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. | |
ROSE_DLL_API void | deleteAllNodes () |
Function to delete AST subtree's nodes only, users must take care of any dangling pointers, symbols or types that result. | |
ROSE_DLL_API void | checkSgNodePointers () |
Function to delete AST subtree's nodes only, users must take care of any dangling pointers, symbols or types that result. | |
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). | |
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). | |
ROSE_DLL_API void | moveStatementsBetweenBlocks (SgAdaPackageSpec *sourceBlock, SgNamespaceDefinitionStatement *targetBlock) |
Move statements in Ada's package spec into C++ namespace's definition. | |
ROSE_DLL_API void | moveStatementsBetweenBlocks (SgAdaPackageBody *sourceBlock, SgNamespaceDefinitionStatement *targetBlock) |
Move statements in Ada's package body into C++ namespace's definition. | |
ROSE_DLL_API void | moveStatementsBetweenBlocks (SgNamespaceDefinitionStatement *sourceBlock, SgNamespaceDefinitionStatement *targetBlock) |
Move statements between C++ namespace's definitions. | |
ROSE_DLL_API bool | isLambdaFunction (SgFunctionDeclaration *func) |
Check if a function declaration is a C++11 lambda function. | |
ROSE_DLL_API bool | isLambdaCapturedVariable (SgVarRefExp *varRef) |
check if a variable reference is this->a[i] inside of a lambda function | |
ROSE_DLL_API void | moveVariableDeclaration (SgVariableDeclaration *decl, SgScopeStatement *target_scope) |
Move a variable declaration to a new scope, handle symbol, special scopes like For loop, etc. | |
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. | |
ROSE_DLL_API void | appendStatement (SgStatement *stmt, SgForInitStatement *for_init_stmt) |
Append a statement to the end of SgForInitStatement. | |
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. | |
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). | |
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. | |
ROSE_DLL_API void | prependStatement (SgStatement *stmt, SgForInitStatement *for_init_stmt) |
Prepend a statement to the beginning of SgForInitStatement. | |
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 | |
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 . | |
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. | |
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. | |
ROSE_DLL_API void | insertStatementBefore (SgStatement *targetStmt, SgStatement *newStmt, bool autoMovePreprocessingInfo=true) |
Insert a statement before a target statement. | |
ROSE_DLL_API void | insertStatementListBefore (SgStatement *targetStmt, const std::vector< SgStatement * > &newStmts) |
Insert a list of statements before a target statement. | |
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. | |
ROSE_DLL_API void | insertStatementListAfter (SgStatement *targetStmt, const std::vector< SgStatement * > &newStmt) |
Insert a list of statements after a target statement. | |
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. | |
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. | |
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. | |
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. | |
ROSE_DLL_API SgStatement * | lastFrontEndSpecificStatement (SgGlobal *globalScope) |
Function to delete AST subtree's nodes only, users must take care of any dangling pointers, symbols or types that result. | |
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()). | |
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() | |
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. | |
ROSE_DLL_API SgNode * | 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. | |
ROSE_DLL_API void | replaceVariableReferences (SgVariableSymbol *old_sym, SgVariableSymbol *new_sym, SgScopeStatement *scope) |
Replace all variable references to an old symbol in a scope to being references to a new symbol. | |
ROSE_DLL_API bool | statementCanBeTransformed (SgStatement *stmt) |
If header file unparsing and token-based unparsing are used, then some statements in header files used with the same name and different include syntax can't be transformed. | |
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. | |
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. | |
ROSE_DLL_API SgVariableSymbol * | appendArg (SgFunctionParameterList *, SgInitializedName *) |
Append an argument to SgFunctionParameterList, transparently set parent,scope, and symbols for arguments when possible. | |
ROSE_DLL_API SgVariableSymbol * | prependArg (SgFunctionParameterList *, SgInitializedName *) |
Prepend an argument to SgFunctionParameterList. | |
ROSE_DLL_API void | appendExpression (SgExprListExp *, SgExpression *) |
Append an expression to a SgExprListExp, set the parent pointer also. | |
ROSE_DLL_API void | appendExpressionList (SgExprListExp *, const std::vector< SgExpression * > &) |
Append an expression list to a SgExprListExp, set the parent pointers also. | |
template<class actualFunction > | |
void | setParameterList (actualFunction *func, SgFunctionParameterList *paralist) |
Set parameter list for a function declaration, considering existing parameter list etc. | |
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. | |
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. | |
ROSE_DLL_API void | replaceExpressionWithStatement (SgExpression *from, SageInterface::StatementGenerator *to) |
Replace a given expression with a list of statements produced by a generator. | |
ROSE_DLL_API void | replaceSubexpressionWithStatement (SgExpression *from, SageInterface::StatementGenerator *to) |
Similar to replaceExpressionWithStatement, but with more restrictions. | |
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. | |
ROSE_DLL_API void | setLhsOperand (SgExpression *target, SgExpression *lhs) |
set left hand operand for binary expressions, transparently downcasting target expressions when necessary | |
ROSE_DLL_API void | setRhsOperand (SgExpression *target, SgExpression *rhs) |
set left hand operand for binary expression | |
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. | |
ROSE_DLL_API void | moveToSubdirectory (std::string directoryName, SgFile *file) |
Move file to be generated in a subdirectory (will be generated by the unparser). | |
ROSE_DLL_API SgStatement * | findSurroundingStatementFromSameFile (SgStatement *targetStmt, bool &surroundingStatementPreceedsTargetStatement) |
Supporting function to comment relocation in insertStatement() and removeStatement(). | |
ROSE_DLL_API void | moveCommentsToNewStatement (SgStatement *sourceStatement, const std::vector< int > &indexList, SgStatement *destinationStatement, bool destinationStatementPreceedsSourceStatement) |
Relocate comments and CPP directives from one statement to another. | |
ROSE_DLL_API void | moveDeclarationToAssociatedNamespace (SgDeclarationStatement *declarationStatement) |
Relocate the declaration to be explicitly represented in its associated namespace (required for some backend compilers to process template instantiations). | |
ROSE_DLL_API bool | isTemplateInstantiationNode (SgNode *node) |
Function to delete AST subtree's nodes only, users must take care of any dangling pointers, symbols or types that result. | |
ROSE_DLL_API void | wrapAllTemplateInstantiationsInAssociatedNamespaces (SgProject *root) |
Function to delete AST subtree's nodes only, users must take care of any dangling pointers, symbols or types that result. | |
ROSE_DLL_API void | resetInternalMapsForTargetStatement (SgStatement *sourceStatement) |
Reset internal data structures used for token-based unparsing and macro summaries based on modifications to this statement. | |
ROSE_DLL_API void | convertFunctionDefinitionsToFunctionPrototypes (SgNode *node) |
XXX This function operates on the new file used to support outlined function definitions. We use a copy of the file where the code will be outlined FROM, so that if there are references to declarations in the outlined code we can support the outpiled code with those references. This approach has the added advantage of also supporting the same include file tree as the original file where the outlined code is being taken from. | |
ROSE_DLL_API SgFunctionDeclaration * | replaceDefiningFunctionDeclarationWithFunctionPrototype (SgFunctionDeclaration *functionDeclaration) |
Function to delete AST subtree's nodes only, users must take care of any dangling pointers, symbols or types that result. | |
ROSE_DLL_API std::vector< SgFunctionDeclaration * > | generateFunctionDefinitionsList (SgNode *node) |
Function to delete AST subtree's nodes only, users must take care of any dangling pointers, symbols or types that result. | |
ROSE_DLL_API SgFunctionDeclaration * | buildFunctionPrototype (SgFunctionDeclaration *functionDeclaration) |
Function to delete AST subtree's nodes only, users must take care of any dangling pointers, symbols or types that result. | |
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, bool cleanUnusedSymbol=true) |
Connect variable reference to the right variable symbols when feasible, return the number of references being fixed. | |
ROSE_DLL_API void | fixVariableDeclaration (SgVariableDeclaration *varDecl, SgScopeStatement *scope) |
Patch up symbol, scope, and parent information when a SgVariableDeclaration's scope is known. | |
ROSE_DLL_API 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. | |
ROSE_DLL_API 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. | |
ROSE_DLL_API 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. | |
ROSE_DLL_API 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. | |
ROSE_DLL_API void | setFortranNumericLabel (SgStatement *stmt, int label_value, SgLabelSymbol::label_type_enum label_type=SgLabelSymbol::e_start_label_type, SgScopeStatement *label_scope=NULL) |
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. | |
ROSE_DLL_API int | suggestNextNumericLabel (SgFunctionDefinition *func_def) |
Suggest next usable (non-conflicting) numeric label value for a Fortran function definition scope. | |
ROSE_DLL_API void | fixFunctionDeclaration (SgFunctionDeclaration *stmt, SgScopeStatement *scope) |
Fix the symbol table and set scope (only if scope in declaration is not already set). | |
ROSE_DLL_API void | fixTemplateDeclaration (SgTemplateDeclaration *stmt, SgScopeStatement *scope) |
Fix the symbol table and set scope (only if scope in declaration is not already set). | |
ROSE_DLL_API 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. | |
ROSE_DLL_API std::set< SgStatement * > | collectTransformedStatements (SgNode *node) |
This collects the statements that are marked as transformed (useful in debugging). | |
ROSE_DLL_API std::set< SgStatement * > | collectModifiedStatements (SgNode *node) |
This collects the statements that are marked as modified (a flag automatically set by all set_* generated functions) (useful in debugging). | |
ROSE_DLL_API std::set< SgLocatedNode * > | collectModifiedLocatedNodes (SgNode *node) |
This collects the SgLocatedNodes that are marked as modified (a flag automatically set by all set_* generated functions) (useful in debugging). | |
ROSE_DLL_API void | resetModifiedLocatedNodes (const std::set< SgLocatedNode * > &modifiedNodeSet) |
Use the set of IR nodes and set the isModified flag in each IR node to true. | |
ROSE_DLL_API void | reportModifiedStatements (const std::string &label, SgNode *node) |
Connect variable reference to the right variable symbols when feasible, return the number of references being fixed. | |
ROSE_DLL_API void | reportModifiedLocatedNodes (const std::string &label, SgNode *node) |
Connect variable reference to the right variable symbols when feasible, return the number of references being fixed. | |
ROSE_DLL_API void | translateToUseCppDeclarations (SgNode *n) |
Connect variable reference to the right variable symbols when feasible, return the number of references being fixed. | |
ROSE_DLL_API void | translateScopeToUseCppDeclarations (SgScopeStatement *scope) |
Connect variable reference to the right variable symbols when feasible, return the number of references being fixed. | |
ROSE_DLL_API std::vector< SgC_PreprocessorDirectiveStatement * > | translateStatementToUseCppDeclarations (SgStatement *statement, SgScopeStatement *scope) |
Connect variable reference to the right variable symbols when feasible, return the number of references being fixed. | |
ROSE_DLL_API void | printOutComments (SgLocatedNode *locatedNode) |
Connect variable reference to the right variable symbols when feasible, return the number of references being fixed. | |
ROSE_DLL_API bool | skipTranslateToUseCppDeclaration (PreprocessingInfo *currentPreprocessingInfo) |
Connect variable reference to the right variable symbols when feasible, return the number of references being fixed. | |
ROSE_DLL_API void | outputFileIds (SgNode *node) |
Connect variable reference to the right variable symbols when feasible, return the number of references being fixed. | |
ROSE_DLL_API 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. | |
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++. | |
ROSE_DLL_API bool | collectReadWriteVariables (SgStatement *stmt, std::set< SgInitializedName * > &readVars, std::set< SgInitializedName * > &writeVars, bool coarseGrain=true) |
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. For accesses to members of aggregate data, we return the coarse grain aggregate mem obj by default. | |
ROSE_DLL_API void | collectReadOnlyVariables (SgStatement *stmt, std::set< SgInitializedName * > &readOnlyVars, bool coarseGrain=true) |
Collect read only variables within a statement. The statement can be either of a function, a scope, or a single line statement. For accesses to members of aggregate data, we return the coarse grain aggregate mem obj by default. | |
ROSE_DLL_API void | collectReadOnlySymbols (SgStatement *stmt, std::set< SgVariableSymbol * > &readOnlySymbols, bool coarseGrain=true) |
Collect read only variable symbols within a statement. The statement can be either of a function, a scope, or a single line statement. For accesses to members of aggregate data, we return the coarse grain aggregate mem obj by default. | |
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++. | |
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++. | |
ROSE_DLL_API LivenessAnalysis * | call_liveness_analysis (SgProject *project, bool debug=false) |
Call liveness analysis on an entire project. | |
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. | |
ROSE_DLL_API void | ReductionRecognition (SgForStatement *loop, std::set< std::pair< SgInitializedName *, OmpSupport::omp_construct_enum > > &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 | 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! | |
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 (with duplicated statement s) and return expressions with side effects. Return the number of statements inserted. | |
ROSE_DLL_API void | removeJumpsToNextStatement (SgNode *) |
Remove jumps whose label is immediately after the jump. Used to clean up inlined code fragments. | |
ROSE_DLL_API void | removeUnusedLabels (SgNode *top, bool keepChild=false) |
Remove labels which are not targets of any goto statements: its child statement is also removed by default. | |
ROSE_DLL_API std::set< SgLabelStatement * > | findUnusedLabels (SgNode *top) |
Find unused labels which are not targets of any goto statements. | |
ROSE_DLL_API void | removeConsecutiveLabels (SgNode *top) |
Remove consecutive labels. | |
ROSE_DLL_API bool | mergeDeclarationAndAssignment (SgVariableDeclaration *decl, SgExprStatement *assign_stmt, bool removeAssignStmt=true) |
Merge a variable assignment statement into a matching variable declaration statement. Callers should make sure the merge is semantically correct (by not introducing compilation errors). This function simply does the merge transformation, without eligibility check. | |
ROSE_DLL_API bool | mergeAssignmentWithDeclaration (SgExprStatement *assign_stmt, SgVariableDeclaration *decl, bool removeAssignStmt=true) |
Merge an assignment into its upstream declaration statement. Callers should make sure the merge is semantically correct. | |
ROSE_DLL_API bool | mergeDeclarationWithAssignment (SgVariableDeclaration *decl, SgExprStatement *assign_stmt) |
Merge a declaration statement into a matching followed variable assignment. Callers should make sure the merge is semantically correct (by not introducing compilation errors). This function simply does the merge transformation, without eligibility check. | |
ROSE_DLL_API SgExprStatement * | splitVariableDeclaration (SgVariableDeclaration *decl) |
Split a variable declaration with an rhs assignment into two statements: a declaration and an assignment. | |
ROSE_DLL_API int | splitVariableDeclaration (SgScopeStatement *scope, bool topLevelOnly=true) |
Split declarations within a scope into declarations and assignment statements, by default only top level declarations are considered. Return the number of declarations split. | |
ROSE_DLL_API SgAssignInitializer * | splitExpression (SgExpression *from, std::string newName="") |
Replace an expression with a temporary variable and an assignment statement. | |
ROSE_DLL_API void | splitExpressionIntoBasicBlock (SgExpression *expr) |
Split long expressions into blocks of statements. | |
ROSE_DLL_API void | removeLabeledGotos (SgNode *top) |
Remove labeled goto statements. | |
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. | |
ROSE_DLL_API SgBasicBlock * | ensureBasicBlockAsBodyOfFor (SgForStatement *fs) |
Check if the body of a 'for' statement is a SgBasicBlock, create one if not. | |
ROSE_DLL_API SgBasicBlock * | ensureBasicBlockAsBodyOfUpcForAll (SgUpcForAllStatement *fs) |
Check if the body of a 'upc_forall' statement is a SgBasicBlock, create one if not. | |
ROSE_DLL_API SgBasicBlock * | ensureBasicBlockAsBodyOfWhile (SgWhileStmt *ws) |
Check if the body of a 'while' statement is a SgBasicBlock, create one if not. | |
ROSE_DLL_API SgBasicBlock * | ensureBasicBlockAsBodyOfDoWhile (SgDoWhileStmt *ws) |
Check if the body of a 'do .. while' statement is a SgBasicBlock, create one if not. | |
ROSE_DLL_API SgBasicBlock * | ensureBasicBlockAsBodyOfSwitch (SgSwitchStatement *ws) |
Check if the body of a 'switch' statement is a SgBasicBlock, create one if not. | |
SgBasicBlock * | ensureBasicBlockAsBodyOfCaseOption (SgCaseOptionStmt *cs) |
Check if the body of a 'case option' statement is a SgBasicBlock, create one if not. | |
SgBasicBlock * | ensureBasicBlockAsBodyOfDefaultOption (SgDefaultOptionStmt *cs) |
Check if the body of a 'default option' statement is a SgBasicBlock, create one if not. | |
ROSE_DLL_API SgBasicBlock * | ensureBasicBlockAsTrueBodyOfIf (SgIfStmt *ifs) |
Check if the true body of a 'if' statement is a SgBasicBlock, create one if not. | |
ROSE_DLL_API SgBasicBlock * | ensureBasicBlockAsFalseBodyOfIf (SgIfStmt *ifs, bool createEmptyBody=true) |
Check if the false body of a 'if' statement is a SgBasicBlock, create one if not when the flag is true. | |
ROSE_DLL_API SgBasicBlock * | ensureBasicBlockAsBodyOfCatch (SgCatchOptionStmt *cos) |
Check if the body of a 'catch' statement is a SgBasicBlock, create one if not. | |
ROSE_DLL_API SgBasicBlock * | ensureBasicBlockAsBodyOfOmpBodyStmt (SgOmpBodyStatement *ompbodyStmt) |
Check if the body of a SgOmpBodyStatement is a SgBasicBlock, create one if not. | |
ROSE_DLL_API void | cleanupNontransformedBasicBlockNode () |
Remove unused basic block IR nodes added as part of normalization. | |
ROSE_DLL_API void | recordNormalizations (SgStatement *s) |
Record where normalization have been done so that we can preform denormalizations as required for the token-based unparsing to generate minimal diffs. | |
ROSE_DLL_API int | normalizeArrowExpWithAddressOfLeftOperand (SgNode *root, bool transformationGeneratedOnly=true) |
Convert all code within root matching the patern of (&left)->right, and translate them into left.right. Return the number of matches of the pattern. Be default, only transformation generated nodes will be normalized. | |
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. | |
void | changeAllBodiesToBlocks (SgNode *top, bool createEmptyBody=true) |
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. | |
SgBasicBlock * | 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 | getIntegerConstantValue (SgValueExp *expr) |
Get the constant value from a constant integer expression; abort on everything else. | |
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. | |
SgCommaOpExp * | 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 * | 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 * > | 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 . | |
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. | |
SgInitializedName & | getFirstVariable (SgVariableDeclaration &vardecl) |
convenience function that returns the first initialized name in a list of variable declarations. | |
bool | hasTemplateSyntax (const SgName &name) |
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++. | |
std::set< unsigned int > | collectSourceSequenceNumbers (SgNode *astNode) |
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++. | |
bool | HasNoThrowAssign (const SgType *const inputType) |
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++. | |
bool | HasNoThrowCopy (const SgType *const inputType) |
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++. | |
bool | HasNoThrowConstructor (const SgType *const inputType) |
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++. | |
bool | HasTrivialAssign (const SgType *const inputType) |
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++. | |
bool | HasTrivialCopy (const SgType *const inputType) |
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++. | |
bool | HasTrivialConstructor (const SgType *const inputType) |
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++. | |
bool | HasTrivialDestructor (const SgType *const inputType) |
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++. | |
bool | HasVirtualDestructor (const SgType *const inputType) |
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++. | |
bool | IsBaseOf (const SgType *const inputBaseType, const SgType *const inputDerivedType) |
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++. | |
bool | IsAbstract (const SgType *const inputType) |
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++. | |
bool | IsClass (const SgType *const inputType) |
strip off typedef and modifer types, then check if a type is a class type, excluding union type. | |
bool | IsEmpty (const SgType *const inputType) |
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++. | |
bool | IsEnum (const SgType *const inputType) |
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++. | |
bool | IsPod (const SgType *const inputType) |
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++. | |
bool | IsPolymorphic (const SgType *const inputType) |
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++. | |
bool | IsStandardLayout (const SgType *const inputType) |
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++. | |
bool | IsLiteralType (const SgType *const inputType) |
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++. | |
bool | IsTrivial (const SgType *const inputType) |
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++. | |
bool | IsUnion (const SgType *const inputType) |
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++. | |
SgType * | UnderlyingType (SgType *type) |
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++. | |
bool | isStructurallyEquivalentAST (SgNode *tree1, SgNode *tree2) |
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++. | |
struct const_int_expr_t | evaluateConstIntegerExpression (SgExpression *expr) |
The function tries to evaluate const integer expressions (such as are used in array dimension sizes). It follows variable symbols, and requires constness. | |
bool | checkTypesAreEqual (SgType *typeA, SgType *typeB) |
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 std::string | getTempDirectory (SgProject *project) |
Create a temporary directory if it does not yet exist and return its name. | |
ROSE_DLL_API void | destroyTempDirectory (std::string) |
Use the system command to remove a temporary directory and all its containing files. | |
ROSE_DLL_API SgFile * | processFile (SgProject *, std::string, bool unparse=false) |
Invoke JavaRose to translate a given file and put the resulting AST in the global space of the project. | |
ROSE_DLL_API std::string | preprocessPackage (SgProject *, std::string) |
Using the package_name, create a file with a package statement, translate it in order to load the package into the project. | |
ROSE_DLL_API std::string | preprocessImport (SgProject *, std::string) |
Using the import_string parameter, create a file with the relevant import statement; translate the file and add its AST to the project. | |
ROSE_DLL_API SgFile * | preprocessCompilationUnit (SgProject *, std::string, std::string, bool unparse=true) |
Using the file_content string, create a file with the content in question; build its AST and add it to the project. | |
ROSE_DLL_API SgClassDefinition * | findJavaPackage (SgScopeStatement *, std::string) |
Look for a qualified package name in the given scope and return its package definition. | |
ROSE_DLL_API SgClassDefinition * | findOrInsertJavaPackage (SgProject *, std::string, bool create_directory=false) |
Process a qualified package name, if needed, and return its package definition. | |
ROSE_DLL_API SgClassDeclaration * | findOrImportJavaClass (SgProject *, SgClassDefinition *package_definition, std::string) |
If the class_name already exists in the scope, return it. | |
ROSE_DLL_API SgClassDeclaration * | findOrImportJavaClass (SgProject *, std::string, std::string) |
If the class_name already exists in the scope, return it. | |
ROSE_DLL_API SgClassDeclaration * | findOrImportJavaClass (SgProject *, SgClassType *) |
If the class_name already exists in the scope, return it. | |
ROSE_DLL_API SgMemberFunctionDeclaration * | findJavaMain (SgClassDefinition *) |
Find a main method in a Java class. | |
ROSE_DLL_API SgMemberFunctionDeclaration * | findJavaMain (SgClassType *) |
Find a main method in a Java class. | |
template<class T > | |
bool | isTemplateInstantiationFromTemplateDeclarationSatisfyingFilter (SgFunctionDeclaration *function, T *filter) |
This function detects template instantiations that are relevant when filters are used. | |
void | detectCycleInType (SgType *type, const std::string &from) |
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++. | |
void | checkForInitializers (SgNode *node) |
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++. | |
void | clearSharedGlobalScopes (SgProject *project) |
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++. | |
Variables | |
ROSE_DLL_API Transformation_Record | trans_records |
ROSE_DLL_API int | gensym_counter = 0 |
An internal counter for generating unique SgName. | |
vector< SgBasicBlock * > | addedBasicBlockNodes |
Stringify | |
Generate a useful string (name) to describe a SgNode | |
std::map< std::string, int > | local_name_collision_map |
Global map of name collisions to support generateUniqueNameForUseAsIdentifier() function. | |
std::map< std::string, SgNode * > | local_name_to_node_map |
Global map of name collisions to support generateUniqueNameForUseAsIdentifier() function. | |
std::map< SgNode *, std::string > | local_node_to_name_map |
Global map of name collisions to support generateUniqueNameForUseAsIdentifier() function. | |
std::string | get_name (const SgNode *node) |
Generate a useful name to describe the SgNode. | |
std::string | get_name (const SgStatement *stmt) |
Generate a useful name to describe the declaration. | |
std::string | get_name (const SgExpression *expr) |
Generate a useful name to describe the expression. | |
std::string | get_name (const SgDeclarationStatement *declaration) |
Generate a useful name to describe the declaration. | |
std::string | get_name (const SgScopeStatement *scope) |
Generate a useful name to describe the scope. | |
std::string | get_name (const SgSymbol *symbol) |
Generate a useful name to describe the SgSymbol. | |
std::string | get_name (const SgType *type) |
Generate a useful name to describe the SgType. | |
std::string | get_name (const SgSupport *node) |
Generate a useful name to describe the SgSupport IR node. | |
std::string | get_name (const SgLocatedNodeSupport *node) |
Generate a useful name to describe the SgLocatedNodeSupport IR node. | |
std::string | get_name (const SgC_PreprocessorDirectiveStatement *directive) |
Generate a useful name to describe the SgC_PreprocessorDirectiveStatement IR node. | |
std::string | get_name (const SgToken *token) |
Generate a useful name to describe the SgToken IR node. | |
SgNamedType * | getDeclaredType (const SgDeclarationStatement *declaration) |
Returns the type introduced by a declaration. | |
std::string | generateUniqueNameForUseAsIdentifier (SgDeclarationStatement *declaration) |
Generate a useful name to support construction of identifiers from declarations. | |
std::string | generateUniqueNameForUseAsIdentifier_support (SgDeclarationStatement *declaration) |
Global map of name collisions to support generateUniqueNameForUseAsIdentifier() function. | |
void | computeUniqueNameForUseAsIdentifier (SgNode *astNode) |
Traversal to set the global map of names to node and node to names.collisions to support generateUniqueNameForUseAsIdentifier() function. | |
void | reset_name_collision_map () |
Reset map variables used to support generateUniqueNameForUseAsIdentifier() function. | |
Definition at line 38 of file sageInterfaceAsm.h.
void SageInterface::setOneSourcePositionForTransformation | ( | SgNode * | root | ) |
Set current node's source position as transformation generated.
Definition at line 7245 of file sageInterface.C.
References setSourcePosition().
Referenced by SageBuilder::buildActualArgumentExpression(), SageBuilder::buildAggregateInitializer(), SageBuilder::buildAlignOfOp(), SageBuilder::buildAlignOfOp(), SageBuilder::buildAsmStatement(), SageBuilder::buildAssertStmt(), SageBuilder::buildAssertStmt(), SageBuilder::buildAssignInitializer(), SageBuilder::buildAssignStatement(), SageBuilder::buildAssignStatement_ast_translate(), SageBuilder::buildAsyncStmt(), SageBuilder::buildAtomicStmt(), SageBuilder::buildAwaitExpression(), SageBuilder::buildBasicBlock(), SageBuilder::buildBinaryExpression(), SageBuilder::buildBoolValExp(), SageBuilder::buildBracedInitializer(), SageBuilder::buildBreakStmt(), SageBuilder::buildCaseOptionStmt(), SageBuilder::buildCastExp(), SageBuilder::buildCatchOptionStmt(), SageBuilder::buildChar16Val(), SageBuilder::buildChar32Val(), SageBuilder::buildCharVal(), SageBuilder::buildChooseExpression(), SageBuilder::buildClassDeclaration_nfi(), SageBuilder::buildClassDefinition(), SageBuilder::buildClassExp(), SageBuilder::buildClassNameRefExp(), SageBuilder::buildColonShapeExp(), SageBuilder::buildComplexVal(), SageBuilder::buildCompoundInitializer(), SageBuilder::buildCompoundLiteralExp(), SageBuilder::buildComprehension(), SageBuilder::buildConditionalExp(), SageBuilder::buildConstructorInitializer(), SageBuilder::buildContinueStmt(), SageBuilder::buildDefaultOptionStmt(), SageBuilder::buildDefiningClassDeclaration(), SageBuilder::buildDeleteExp(), SageBuilder::buildDeleteExp(), SageBuilder::buildDerivedTypeStatement(), SageBuilder::buildDictionaryComprehension(), SageBuilder::buildDictionaryExp(), SageBuilder::buildDoubleVal(), SageBuilder::buildDoWhileStmt(), SageBuilder::buildEmptyDeclaration(), SageBuilder::buildEnumDeclaration(), SageBuilder::buildEnumVal(), SageBuilder::buildEquivalenceStatement(), SageBuilder::buildExecStatement(), SageBuilder::buildExprListExp(), SageBuilder::buildExprListExp(), SageBuilder::buildExprStatement(), SageBuilder::buildFinishStmt(), SageBuilder::buildFloat128Val(), SageBuilder::buildFloat80Val(), SageBuilder::buildFloatVal(), SageBuilder::buildFoldExpression(), SageBuilder::buildForInitStatement(), SageBuilder::buildForStatement(), SageBuilder::buildFortranContinueStmt(), SageBuilder::buildFortranDo(), SageBuilder::buildFunctionCallExp(), SageBuilder::buildFunctionCallExp(), SageBuilder::buildFunctionCallExp(), SageBuilder::buildFunctionParameterList(), SageBuilder::buildFunctionRefExp(), SageBuilder::buildFunctionRefExp(), SageBuilder::buildFunctionRefExp(), SageBuilder::buildGotoStatement(), SageBuilder::buildIfStmt(), SageBuilder::buildImaginaryVal(), SageBuilder::buildImaginaryVal(), SageBuilder::buildIntVal(), SageBuilder::buildIntValHex(), SageBuilder::buildJavaInstanceOfOp(), SageBuilder::buildJavaLabelStatement(), SageBuilder::buildJovialTableStatement(), SageBuilder::buildJovialTableType(), SageBuilder::buildKeyDatumPair(), SageBuilder::buildLabelRefExp(), SageBuilder::buildLabelStatement(), SageBuilder::buildLabelStatement_nfi(), SageBuilder::buildLambdaRefExp(), SageBuilder::buildListComprehension_nfi(), SageBuilder::buildListExp(), SageBuilder::buildLongDoubleVal(), SageBuilder::buildLongIntVal(), SageBuilder::buildLongLongIntVal(), SageBuilder::buildMagicColonExp(), SageBuilder::buildMatlabForStatement(), SageBuilder::buildMatrixExp(), SageBuilder::buildMemberFunctionRefExp(), SageBuilder::buildMicrosoftAttributeDeclaration(), SageBuilder::buildModuleStatement(), SageBuilder::buildNamespaceAliasDeclarationStatement(), SageBuilder::buildNamespaceDeclaration(), SageBuilder::buildNamespaceDefinition(), SageBuilder::buildNaryBooleanOp(), SageBuilder::buildNaryComparisonOp(), SageBuilder::buildNewExp(), SageBuilder::buildNoexceptOp(), SageBuilder::buildNondefiningClassDeclaration(), SageBuilder::buildNondefiningTemplateClassDeclaration_nfi(), SageBuilder::buildNullExpression(), SageBuilder::buildNullptrValExp(), SageBuilder::buildNullStatement(), SageBuilder::buildOpaqueType(), SageBuilder::buildPassStatement(), SageBuilder::buildPragma(), SageBuilder::buildPragmaDeclaration(), SageBuilder::buildPythonGlobalStmt(), SageBuilder::buildPythonPrintStmt(), SageBuilder::buildRangeExp(), SageBuilder::buildReturnStmt(), SageBuilder::buildSetComprehension(), SageBuilder::buildShortVal(), SageBuilder::buildShortValHex(), SageBuilder::buildSizeOfOp(), SageBuilder::buildSizeOfOp(), SageBuilder::buildStatementExpression(), SageBuilder::buildStaticAssertionDeclaration(), SageBuilder::buildStmtDeclarationStatement(), SageBuilder::buildStringConversion(), SageBuilder::buildStringVal(), SageBuilder::buildStructDeclaration(), SageBuilder::buildSuperExp(), SageBuilder::buildSwitchStatement(), SageBuilder::buildTemplateClassDeclaration_nfi(), SageBuilder::buildTemplateClassDefinition(), SageBuilder::buildTemplateParameter(), SageBuilder::buildTemplateParameterVal(), SageBuilder::buildTemplateType(), SageBuilder::buildTemplateVariableDeclaration(), SageBuilder::buildThisExp(), SageBuilder::buildThrowOp(), SageBuilder::buildTupleExp(), SageBuilder::buildTupleType(), SageBuilder::buildTypedefDeclaration(), SageBuilder::buildTypeIdOp(), SageBuilder::buildUnaryExpression(), SageBuilder::buildUnsignedCharVal(), SageBuilder::buildUnsignedCharValHex(), SageBuilder::buildUnsignedIntVal(), SageBuilder::buildUnsignedIntValHex(), SageBuilder::buildUnsignedLongLongIntVal(), SageBuilder::buildUnsignedLongLongIntValHex(), SageBuilder::buildUnsignedLongVal(), SageBuilder::buildUnsignedLongValHex(), SageBuilder::buildUnsignedShortVal(), SageBuilder::buildUnsignedShortValHex(), SageBuilder::buildUpcMythread(), SageBuilder::buildUpcThreads(), SageBuilder::buildUsingDirectiveStatement(), SageBuilder::buildVariableDeclaration(), SageBuilder::buildVariantExpression(), SageBuilder::buildVarRefExp(), SageBuilder::buildVarRefExp(), SageBuilder::buildVarRefExp(), SageBuilder::buildVoidVal(), SageBuilder::buildWcharVal(), SageBuilder::buildWhileStmt(), SageBuilder::buildWithStatement(), SageBuilder::buildYieldExpression(), initializeSwitchStatement(), and setSourcePositionForTransformation().
void SageInterface::setSourcePosition | ( | SgNode * | node | ) |
Set the source code positon for the current (input) node.
Definition at line 7462 of file sageInterface.C.
References SgNode::class_name(), SageBuilder::display(), SageBuilder::e_sourcePosition_last, SageBuilder::e_sourcePositionCompilerGenerated, SageBuilder::e_sourcePositionDefault, SageBuilder::e_sourcePositionFrontendConstruction, SageBuilder::e_sourcePositionNullPointers, SageBuilder::e_sourcePositionTransformation, SgNode::get_file_info(), SageBuilder::getSourcePositionClassificationMode(), setSourcePositionAsTransformation(), and setSourcePositionPointersToNull().
Referenced by SageBuilder::buildArrayType(), SageBuilder::buildAssignInitializer_nfi(), SageBuilder::buildAtExp(), SageBuilder::buildAtStmt(), SageBuilder::buildBinaryExpression_nfi(), SageBuilder::buildCatchStatementSeq(), SageBuilder::buildDeclarationScope(), SageBuilder::buildFinishExp(), SageBuilder::buildForInitStatement(), SageBuilder::buildForInitStatement(), SageBuilder::buildForInitStatement_nfi(), SageBuilder::buildFunctionParameterRefExp(), SageBuilder::buildJavaSynchronizedStatement(), SageBuilder::buildJovialDefineDeclaration_nfi(), SageBuilder::buildLambdaCapture(), SageBuilder::buildLambdaCaptureList(), SageBuilder::buildLambdaExp(), SageBuilder::buildNondefiningClassDeclaration_nfi(), SageBuilder::buildNondefiningTemplateClassDeclaration_nfi(), SageBuilder::buildNonrealDecl(), SageBuilder::buildSubscriptExpression_nfi(), SageBuilder::buildTemplateClassDeclaration_nfi(), SageBuilder::buildTemplateVariableDeclaration_nfi(), SageBuilder::buildTryStmt(), SageBuilder::buildTryStmt(), SageBuilder::buildTypeExpression(), SageBuilder::buildUnaryExpression_nfi(), SageBuilder::buildVariableDeclaration_nfi(), SageBuilder::buildWhenStmt(), setOneSourcePositionForTransformation(), setOneSourcePositionNull(), and setSourcePositionAtRootAndAllChildren().
SageInterface::DeclarationSets * SageInterface::buildDeclarationSets | ( | SgNode * | n | ) |
Definition at line 564 of file sageInterface.C.
void SageInterface::addMessageStatement | ( | SgStatement * | stmt, |
std::string | message | ||
) |
Function to add "C" style comment to statement.
Definition at line 19965 of file sageInterface.C.
References SgLocatedNode::addToAttachedPreprocessingInfo(), and Sg_File_Info::setTransformation().
Referenced by appendStatementWithDependentDeclaration().
SgSymbol * SageInterface::lookupSymbolInParentScopesIgnoringAliasSymbols | ( | 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.
Definition at line 6730 of file sageInterface.C.
References SgScopeStatement::class_name(), SgSymbol::class_name(), SgNode::get_parent(), SgStatement::get_scope(), and SageBuilder::topScopeStack().
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.
Definition at line 6707 of file sageInterface.C.
References SgNode::get_parent(), SgStatement::get_scope(), and SageBuilder::topScopeStack().
Referenced by generateUniqueVariableName(), lookupNamedTypeInParentScopes(), and lookupVariableSymbolInParentScopes().
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.
Definition at line 6842 of file sageInterface.C.
References SgNode::get_parent(), SgStatement::get_scope(), lookupSymbolInParentScopes(), and SageBuilder::topScopeStack().
Referenced by SageBuilder::buildOpaqueVarRefExp(), SageBuilder::buildVarRefExp(), SageBuilder::fixupCopyOfNodeFromSeparateFileInNewTargetAst(), fixVariableReferences(), and normalizeForLoopInitDeclaration().
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
Definition at line 6528 of file sageInterface.C.
References SgScopeStatement::class_name(), SgNode::get_parent(), SgStatement::get_scope(), and SageBuilder::topScopeStack().
Referenced by SageBuilder::buildFunctionRefExp(), SageBuilder::buildFunctionRefExp(), SageBuilder::buildMemberFunctionCall(), and SageBuilder::fixupCopyOfNodeFromSeparateFileInNewTargetAst().
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
Definition at line 6686 of file sageInterface.C.
References SgNode::get_parent(), SgStatement::get_scope(), and SageBuilder::topScopeStack().
SgFunctionSymbol * SageInterface::lookupTemplateFunctionSymbolInParentScopes | ( | const SgName & | functionName, |
SgFunctionType * | ftype, | ||
SgTemplateParameterPtrList * | tplparams, | ||
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.
Definition at line 6555 of file sageInterface.C.
References SgScopeStatement::class_name(), SgNode::get_parent(), SgStatement::get_scope(), and SageBuilder::topScopeStack().
SgFunctionSymbol * SageInterface::lookupTemplateMemberFunctionSymbolInParentScopes | ( | const SgName & | functionName, |
SgFunctionType * | ftype, | ||
SgTemplateParameterPtrList * | tplparams, | ||
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.
Definition at line 6582 of file sageInterface.C.
References SgScopeStatement::class_name(), SgNode::get_parent(), SgStatement::get_scope(), and SageBuilder::topScopeStack().
SgTemplateVariableSymbol * SageInterface::lookupTemplateVariableSymbolInParentScopes | ( | const SgName & | name, |
SgTemplateParameterPtrList * | tplparams, | ||
SgTemplateArgumentPtrList * | tplargs, | ||
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.
Definition at line 6891 of file sageInterface.C.
References SgScopeStatement::class_name(), SgNode::get_parent(), SgStatement::get_scope(), and SageBuilder::topScopeStack().
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.
Definition at line 6922 of file sageInterface.C.
References SgNode::get_parent(), SgStatement::get_scope(), and SageBuilder::topScopeStack().
Referenced by SageBuilder::buildMemberFunctionCall(), SageBuilder::fixupCopyOfNodeFromSeparateFileInNewTargetAst(), SageBuilder::getTargetFileType(), and SageBuilder::getTargetFileTypeSupport().
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.
Definition at line 6967 of file sageInterface.C.
References SgScopeStatement::class_name(), SgNode::get_parent(), SgStatement::get_scope(), and SageBuilder::topScopeStack().
Referenced by SageBuilder::fixupCopyOfNodeFromSeparateFileInNewTargetAst(), SageBuilder::getTargetFileType(), and SageBuilder::getTargetFileTypeSupport().
SgNonrealSymbol * SageInterface::lookupNonrealSymbolInParentScopes | ( | 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.
Definition at line 6946 of file sageInterface.C.
References SgNode::get_parent(), SgStatement::get_scope(), and SageBuilder::topScopeStack().
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.
Definition at line 7038 of file sageInterface.C.
References SgScopeStatement::class_name(), SgNode::get_parent(), SgStatement::get_scope(), and SageBuilder::topScopeStack().
Referenced by SageBuilder::getTargetFileType().
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.
Definition at line 7067 of file sageInterface.C.
References SgNode::get_parent(), SgStatement::get_scope(), and SageBuilder::topScopeStack().
Referenced by SageBuilder::findAssociatedDeclarationInTargetAST(), SageBuilder::findAssociatedSymbolInTargetAST(), SageBuilder::fixupCopyOfNodeFromSeparateFileInNewTargetAst(), SageBuilder::getTargetFileType(), and SageBuilder::getTargetFileTypeSupport().
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.
Definition at line 7091 of file sageInterface.C.
References SgNode::get_parent(), SgStatement::get_scope(), and SageBuilder::topScopeStack().
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.
Required traversal function
Definition at line 1173 of file sageInterface.C.
References SgScopeStatement::class_name(), SgSymbol::class_name(), SgInitializedName::get_declaration(), get_name(), SgNode::get_parent(), SgScopeStatement::get_symbol_table(), getEnclosingStatement(), SgNode::set_isModified(), SgLocatedNode::setTransformation(), statementCanBeTransformed(), SgVarRefExp::traverseMemoryPoolNodes(), and SgDeclarationStatement::variantT().
void SageInterface::outputGlobalFunctionTypeSymbolTable | ( | ) |
Output function type symbols in global function type symbol table.
Definition at line 3641 of file sageInterface.C.
References SgNode::get_globalFunctionTypeTable().
void SageInterface::outputLocalSymbolTables | ( | SgNode * | node | ) |
Output the local symbol tables.
\implementation Each symbol table is output with the file infor where it is located in the source code.
Definition at line 3657 of file sageInterface.C.
References AstSimpleProcessing::traverse().
void SageInterface::rebuildSymbolTable | ( | SgScopeStatement * | scope | ) |
Regenerate the symbol table.
\implementation current symbol table must be NULL pointer before calling this function (for safety, but is this a good idea?)
Definition at line 4262 of file sageInterface.C.
References SgScopeStatement::class_name(), SgDeclarationStatement::class_name(), SgTemplateDeclaration::class_name(), SgClassDeclaration::class_name(), SgTemplateInstantiationDecl::class_name(), SgFunctionDeclaration::class_name(), SgTemplateInstantiationFunctionDecl::class_name(), SgScopeStatement::generateStatementList(), SgVariableDeclaration::get_baseTypeDefiningDeclaration(), SgTypedefDeclaration::get_baseTypeDefiningDeclaration(), SgWhileStmt::get_condition(), SgIfStmt::get_conditional(), SgDeclarationStatement::get_definingDeclaration(), SgEnumDeclaration::get_enumerators(), SgLocatedNode::get_file_info(), SgDeclarationStatement::get_firstNondefiningDeclaration(), SgSwitchStatement::get_item_selector(), SgEnumDeclaration::get_name(), SgTemplateDeclaration::get_name(), SgNamespaceDeclarationStatement::get_name(), get_name(), SgNamespaceAliasDeclarationStatement::get_namespaceDeclaration(), SgNode::get_parent(), SgTemplateDeclaration::get_scope(), SgClassDeclaration::get_scope(), SgFunctionDeclaration::get_scope(), SgTemplateDeclaration::get_string(), SgScopeStatement::get_symbol_table(), SgDeclarationStatement::get_template_name(), SgTemplateInstantiationMemberFunctionDecl::get_templateDeclaration(), SgVariableDeclaration::get_variableDeclarationContainsBaseTypeDefiningDeclaration(), SgVariableDeclaration::get_variables(), SgScopeStatement::insert_symbol(), SgDeclarationStatement::isForward(), SgDeclarationModifier::isFriend(), SgSymbolTable::print(), SgNode::set_parent(), SgScopeStatement::set_symbol_table(), SgSymbolTable::size(), SgScopeStatement::variantT(), and SgDeclarationStatement::variantT().
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.
Definition at line 15439 of file sageInterface.C.
References SgTypeUnknown::createType(), and SgVariableSymbol::get_name().
Referenced by fixVariableReferences().
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.
Definition at line 5054 of file sageInterface.C.
References SgScopeStatement::class_name(), Rose::AST::Utility::edgePointerReplacement(), get_name(), SgScopeStatement::get_symbol_table(), SgProject::get_verbose(), and SgSymbol::variantT().
string SageInterface::get_name | ( | const SgNode * | node | ) |
Generate a useful name to describe the SgNode.
Definition at line 2976 of file sageInterface.C.
References SgNode::class_name(), and get_name().
Referenced by appendStatementWithDependentDeclaration(), astIntersection(), buildForwardFunctionDeclaration(), SageBuilder::buildJavaLabelStatement(), SageBuilder::buildMemberFunctionType(), SageBuilder::buildNamespaceDeclaration_nfi(), checkAccessPermissions(), deleteAST(), displayScope(), enclosingNamespaceScope(), SageBuilder::findAssociatedDeclarationInTargetAST(), findOrImportJavaClass(), findSurroundingStatementFromSameFile(), fixupReferencesToSymbols(), generateUniqueNameForUseAsIdentifier(), generateUniqueNameForUseAsIdentifier_support(), get_name(), get_name(), get_name(), get_name(), get_name(), get_name(), get_name(), getClassTypeChainForMemberReference(), SageBuilder::getTargetFileType(), SageBuilder::getTargetFileTypeSupport(), isPrototypeInScope(), moveCommentsToNewStatement(), rebuildSymbolTable(), removeStatement(), set_name(), and CollectDependentDeclarationsTraversal::visit().
string SageInterface::get_name | ( | const SgStatement * | stmt | ) |
Generate a useful name to describe the declaration.
Definition at line 2261 of file sageInterface.C.
References SgStatement::class_name(), SgLabelStatement::get_label(), get_name(), and SgStatement::variantT().
string SageInterface::get_name | ( | const SgExpression * | expr | ) |
Generate a useful name to describe the expression.
Definition at line 2725 of file sageInterface.C.
References SgExpression::class_name(), SgBinaryOp::get_lhs_operand(), SgVariableSymbol::get_name(), SgFunctionSymbol::get_name(), SgMemberFunctionSymbol::get_name(), SgClassSymbol::get_name(), SgLabelSymbol::get_name(), get_name(), SgBinaryOp::get_rhs_operand(), Rose::StringUtility::numberToString(), and SgExpression::variantT().
string SageInterface::get_name | ( | const SgDeclarationStatement * | declaration | ) |
Generate a useful name to describe the declaration.
Definition at line 1592 of file sageInterface.C.
References SgDeclarationStatement::class_name(), SgTemplateInstantiationDirectiveStatement::get_declaration(), SgUsingDeclarationStatement::get_declaration(), SgUsingDeclarationStatement::get_initializedName(), SgEnumDeclaration::get_name(), SgTemplateDeclaration::get_name(), SgNamespaceDeclarationStatement::get_name(), SgNamespaceAliasDeclarationStatement::get_name(), get_name(), SgUsingDirectiveStatement::get_namespaceDeclaration(), SgNode::get_parent(), SgTemplateInstantiationDecl::get_templateName(), SgVariableDefinition::get_vardefn(), SgVariableDeclaration::get_variables(), Rose::StringUtility::numberToString(), and SgDeclarationStatement::variantT().
string SageInterface::get_name | ( | const SgScopeStatement * | scope | ) |
Generate a useful name to describe the scope.
Definition at line 2189 of file sageInterface.C.
References SgScopeStatement::class_name(), get_name(), Rose::StringUtility::numberToString(), and SgScopeStatement::variantT().
string SageInterface::get_name | ( | const SgSymbol * | symbol | ) |
Generate a useful name to describe the SgSymbol.
Definition at line 2635 of file sageInterface.C.
References SgSymbol::get_name().
string SageInterface::get_name | ( | const SgType * | type | ) |
Generate a useful name to describe the SgType.
Definition at line 2655 of file sageInterface.C.
References SgType::class_name(), SgNamedType::get_name(), get_name(), SgModifierType::get_typeModifier(), and SgType::variantT().
string SageInterface::get_name | ( | const SgSupport * | node | ) |
Generate a useful name to describe the SgSupport IR node.
Definition at line 2323 of file sageInterface.C.
References SgSupport::class_name(), SgTemplateArgument::get_argumentType(), SgTemplateArgument::get_expression(), get_name(), SgTemplateArgument::get_type(), SgFile::getFileName(), SgTemplateArgument::nontype_argument, SgTemplateParameter::nontype_parameter, SgTemplateParameter::template_parameter, SgTemplateArgument::template_template_argument, SgTemplateArgument::type_argument, SgTemplateParameter::type_parameter, SgNode::unparseToString(), and SgSupport::variantT().
string SageInterface::get_name | ( | const SgLocatedNodeSupport * | node | ) |
Generate a useful name to describe the SgLocatedNodeSupport IR node.
Definition at line 2919 of file sageInterface.C.
References SgLocatedNodeSupport::class_name(), and SgLocatedNodeSupport::variantT().
string SageInterface::get_name | ( | const SgC_PreprocessorDirectiveStatement * | directive | ) |
Generate a useful name to describe the SgC_PreprocessorDirectiveStatement IR node.
Definition at line 1531 of file sageInterface.C.
References SgC_PreprocessorDirectiveStatement::class_name(), and SgC_PreprocessorDirectiveStatement::variantT().
string SageInterface::get_name | ( | const SgToken * | token | ) |
Generate a useful name to describe the SgToken IR node.
Definition at line 3060 of file sageInterface.C.
SgNamedType * SageInterface::getDeclaredType | ( | const SgDeclarationStatement * | declaration | ) |
Returns the type introduced by a declaration.
Definition at line 27472 of file sageInterface.C.
References sg::dispatch().
std::string SageInterface::generateUniqueNameForUseAsIdentifier | ( | SgDeclarationStatement * | declaration | ) |
Generate a useful name to support construction of identifiers from declarations.
This function permits names to be generated that will be unique across translation units (a specific requirement different from the context of the get_name() functions above).
Definition at line 3292 of file sageInterface.C.
References SgDeclarationStatement::class_name(), generateUniqueNameForUseAsIdentifier_support(), SgDeclarationStatement::get_definingDeclaration(), SgDeclarationStatement::get_firstNondefiningDeclaration(), get_name(), local_name_to_node_map, and local_node_to_name_map.
string SageInterface::generateUniqueNameForUseAsIdentifier_support | ( | SgDeclarationStatement * | declaration | ) |
Global map of name collisions to support generateUniqueNameForUseAsIdentifier() function.
Definition at line 3090 of file sageInterface.C.
References SgScopeStatement::class_name(), SgDeclarationStatement::class_name(), Rose::StringUtility::copyEdit(), get_name(), SgClassDeclaration::get_scope(), SgStatement::get_scope(), local_name_collision_map, Rose::StringUtility::numberToString(), and SgDeclarationStatement::variantT().
Referenced by computeUniqueNameForUseAsIdentifier(), and generateUniqueNameForUseAsIdentifier().
void SageInterface::computeUniqueNameForUseAsIdentifier | ( | SgNode * | astNode | ) |
Traversal to set the global map of names to node and node to names.collisions to support generateUniqueNameForUseAsIdentifier() function.
Definition at line 3346 of file sageInterface.C.
References generateUniqueNameForUseAsIdentifier_support(), local_name_collision_map, local_name_to_node_map, and local_node_to_name_map.
void SageInterface::reset_name_collision_map | ( | ) |
Reset map variables used to support generateUniqueNameForUseAsIdentifier() function.
Definition at line 3081 of file sageInterface.C.
References local_name_collision_map, local_name_to_node_map, and local_node_to_name_map.
SgMemberFunctionDeclaration * SageInterface::getDefaultDestructor | ( | SgClassDeclaration * | classDeclaration | ) |
Get the default destructor from the class declaration.
Definition at line 3426 of file sageInterface.C.
References SgNode::class_name(), SgDeclarationStatement::get_definingDeclaration(), SgClassDefinition::get_members(), and SgNode::get_parent().
SgMemberFunctionDeclaration * SageInterface::getDefaultConstructor | ( | SgClassDeclaration * | classDeclaration | ) |
Get the default constructor from the class declaration.
Definition at line 3383 of file sageInterface.C.
References SgDeclarationStatement::get_definingDeclaration(), and SgClassDefinition::get_members().
bool SageInterface::templateDefinitionIsInClass | ( | SgTemplateInstantiationMemberFunctionDecl * | memberFunctionDeclaration | ) |
Return true if template definition is in the class, false if outside of class.
Definition at line 3711 of file sageInterface.C.
References SgNode::get_parent(), SgTemplateInstantiationDecl::get_templateDeclaration(), and SgTemplateInstantiationMemberFunctionDecl::get_templateDeclaration().
SgTemplateInstantiationMemberFunctionDecl * SageInterface::buildForwardFunctionDeclaration | ( | SgTemplateInstantiationMemberFunctionDecl * | memberFunctionInstantiation | ) |
Generate a non-defining (forward) declaration from a defining function declaration.
Definition at line 3956 of file sageInterface.C.
References SgTemplateInstantiationMemberFunctionDecl::class_name(), SgDeclarationStatement::get_definingDeclaration(), SgLocatedNode::get_file_info(), SgDeclarationStatement::get_firstNondefiningDeclaration(), get_name(), SgLocatedNode::get_startOfConstruct(), Sg_File_Info::isCompilerGenerated(), SgDeclarationStatement::isForward(), Sg_File_Info::isOutputInCodeGeneration(), SgDeclarationStatement::set_firstNondefiningDeclaration(), and SgNode::variantT().
bool SageInterface::isStructDeclaration | ( | SgNode * | node | ) |
Check if a SgNode is a declaration for a structure.
Definition at line 16862 of file sageInterface.C.
References SgClassDeclaration::e_struct.
Referenced by fixStatement().
bool SageInterface::isUnionDeclaration | ( | SgNode * | node | ) |
Check if a SgNode is a declaration for a union.
Definition at line 16872 of file sageInterface.C.
References SgClassDeclaration::e_union.
bool SageInterface::addDefaultConstructorIfRequired | ( | SgClassType * | classType, |
int | physical_file_id = Sg_File_Info::TRANSFORMATION_FILE_ID |
||
) |
Get the default destructor from the class declaration.
Definition at line 3481 of file sageInterface.C.
References SageBuilder::buildDefaultConstructor(), SgMemberFunctionDeclaration::class_name(), SgFunctionParameterList::get_args(), SgDeclarationStatement::get_definingDeclaration(), SgLocatedNode::get_endOfConstruct(), SgClassDefinition::get_members(), SgNode::get_parent(), SgLocatedNode::get_startOfConstruct(), and markSubtreeToBeUnparsed().
void SageInterface::recursivePrintCurrentAndParent | ( | SgNode * | n | ) |
Recursively print current and parent nodes. used within gdb to probe the context of a node.
Definition at line 25296 of file sageInterface.C.
References SgNode::class_name(), SgNode::get_parent(), and recursivePrintCurrentAndParent().
Referenced by recursivePrintCurrentAndParent().
void SageInterface::saveToPDF | ( | SgNode * | node, |
std::string | filename | ||
) |
Save AST into a pdf file. Start from a node to find its enclosing file node. The entire file's AST will be saved into a pdf.
Save AST into a json file to post-process into a pdf file, start from a.
Definition at line 25692 of file sageInterface.C.
References getEnclosingFileNode().
Referenced by saveToPDF().
void SageInterface::saveToPDF | ( | SgNode * | node | ) |
Recursively print current and parent nodes. used within gdb to probe the context of a node.
Definition at line 25686 of file sageInterface.C.
References saveToPDF().
void SageInterface::printAST | ( | SgNode * | node | ) |
Pretty print AST horizontally, output to std output.
Definition at line 25638 of file sageInterface.C.
void SageInterface::printAST | ( | SgNode * | node, |
const char * | filename | ||
) |
Pretty print AST horizontally, output to a specified file, a simpiler interface than printAST2TextFile()
Definition at line 25647 of file sageInterface.C.
References printAST2TextFile().
void SageInterface::printAST2TextFile | ( | SgNode * | node, |
const char * | filename, | ||
bool | printType = true |
||
) |
Pretty print AST horizontally, output to a specified text file. If printType is set to false, don't print out type info.
Definition at line 25659 of file sageInterface.C.
Referenced by printAST(), and printAST2TextFile().
void SageInterface::printAST2TextFile | ( | SgNode * | node, |
std::string | filename, | ||
bool | printType = true |
||
) |
Pretty print AST horizontally, output to a specified text file. If printType is set to false, don't print out types info.
Definition at line 25652 of file sageInterface.C.
References printAST2TextFile().
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.
Definition at line 635 of file sageInterface.C.
References SgNode::class_name(), SgNode::get_file_info(), and SgNode::get_parent().
std::string SageInterface::extractPragmaKeyword | ( | const SgPragmaDeclaration * | pragmaDeclaration | ) |
Extract a SgPragmaDeclaration's leading keyword . For example "#pragma omp parallel" has a keyword of "omp".
Definition at line 3786 of file sageInterface.C.
bool SageInterface::isOmpStatement | ( | SgNode * | n | ) |
Check if a node is SgOmp*Statement.
Definition at line 3797 of file sageInterface.C.
bool SageInterface::isOverloaded | ( | SgFunctionDeclaration * | functionDeclaration | ) |
Return true if function is overloaded.
Definition at line 3814 of file sageInterface.C.
References SgClassDefinition::get_declaration(), SgClassDefinition::get_members(), SgTemplateDeclaration::get_name(), SgFunctionDeclaration::get_scope(), and SgFunctionDeclaration::variantT().
void SageInterface::initializeIfStmt | ( | SgIfStmt * | ifstmt, |
SgStatement * | conditional, | ||
SgStatement * | true_body, | ||
SgStatement * | false_body | ||
) |
Support function used for variable declarations in conditionals.
Definition at line 666 of file sageInterface.C.
References SgIfStmt::get_conditional(), SgIfStmt::get_false_body(), SgIfStmt::get_true_body(), is_language_case_insensitive(), SgIfStmt::set_conditional(), SgIfStmt::set_false_body(), SgNode::set_parent(), SgIfStmt::set_true_body(), and setOneSourcePositionNull().
Referenced by SageBuilder::buildIfStmt_nfi().
void SageInterface::initializeSwitchStatement | ( | SgSwitchStatement * | switchStatement, |
SgStatement * | item_selector, | ||
SgStatement * | body | ||
) |
Support function used for variable declarations in conditionals.
Definition at line 696 of file sageInterface.C.
References SgSwitchStatement::get_body(), SgSwitchStatement::get_item_selector(), is_language_case_insensitive(), SgSwitchStatement::set_body(), SgSwitchStatement::set_item_selector(), SgNode::set_parent(), and setOneSourcePositionForTransformation().
Referenced by SageBuilder::buildSwitchStatement_nfi().
void SageInterface::initializeWhileStatement | ( | SgWhileStmt * | whileStatement, |
SgStatement * | condition, | ||
SgStatement * | body, | ||
SgStatement * | else_body | ||
) |
Support function used for variable declarations in conditionals.
Definition at line 719 of file sageInterface.C.
References SgWhileStmt::get_body(), SgWhileStmt::get_condition(), is_language_case_insensitive(), SgWhileStmt::set_body(), SgWhileStmt::set_condition(), SgNode::set_parent(), and setOneSourcePositionNull().
Referenced by SageBuilder::buildWhileStmt_nfi().
void SageInterface::annotateExpressionsWithUniqueNames | ( | SgProject * | project | ) |
Generate unique names for expressions and attach the names as persistent attributes ("UniqueNameAttribute")
Generate unique names for expressions and attach the names as persistent attributes.
Definition at line 23003 of file sageInterface.C.
References SgLocatedNode::addNewAttribute(), SgExpression::class_name(), generateUniqueName(), and SgGraphTraversal< CFG >::traverse().
bool SageInterface::isMain | ( | const SgNode * | node | ) |
Check if a SgNode is a main() function declaration.
Definition at line 7840 of file sageInterface.C.
References SgStatement::get_scope(), is_Fortran_language(), and is_Java_language().
Referenced by findMain().
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;").
\implementation current work does not support expressions.
Referenced by annotateExpressionsWithUniqueNames().
string SageInterface::generateUniqueVariableName | ( | SgScopeStatement * | scope, |
std::string | baseName = "temp" |
||
) |
Generate a name like temp# that is unique in the current scope and any parent and children scopes.
Generate a name that is unique in the current scope and any parent and children scopes.
# is a unique integer counter.
baseName | the word to be included in the variable names. |
baseName | the word to be included in the variable names. |
Definition at line 10932 of file sageInterface.C.
References lookupSymbolInParentScopes().
Referenced by createTempVariableAndReferenceForExpression(), createTempVariableForExpression(), and loopCollapsing().
string SageInterface::generateProjectName | ( | const SgProject * | project, |
bool | supressSuffix = false |
||
) |
Added mechanism to generate project name from list of file names.
Definition at line 6449 of file sageInterface.C.
References SgProject::getAbsolutePathFileNames(), Rose::StringUtility::stripFileSuffixFromFileName(), and Rose::StringUtility::stripPathFromFileName().
SgFunctionDeclaration * SageInterface::getDeclarationOfNamedFunction | ( | SgExpression * | func | ) |
Given a SgExpression that represents a named function (or bound member function), return the mentioned function.
Definition at line 5272 of file sageInterface.C.
References SgExpression::class_name(), and SgBinaryOp::get_rhs_operand().
SgExpression * SageInterface::forallMaskExpression | ( | SgForAllStatement * | stmt | ) |
Get the mask expression from the header of a SgForAllStatement.
Definition at line 5292 of file sageInterface.C.
string SageInterface::getMangledNameFromCache | ( | SgNode * | astNode | ) |
Recursively print current and parent nodes. used within gdb to probe the context of a node.
Definition at line 5903 of file sageInterface.C.
References SgNode::get_globalMangledNameMap(), and SgNode::get_parent().
std::string SageInterface::addMangledNameToCache | ( | SgNode * | astNode, |
const std::string & | mangledName | ||
) |
Recursively print current and parent nodes. used within gdb to probe the context of a node.
Definition at line 5964 of file sageInterface.C.
References SgNode::class_name(), SgStatement::class_name(), Rose::Combinatorics::HasherSha256Builtin::digest(), SgNode::get_globalMangledNameMap(), SgNode::get_parent(), SgStatement::get_scope(), SgNode::get_shortMangledNameCache(), SgStatement::hasExplicitScope(), Rose::Combinatorics::Hasher::insert(), Rose::Combinatorics::Hasher::make64Bits(), and Rose::Combinatorics::toBase62String().
SgDeclarationStatement * SageInterface::getNonInstantiatonDeclarationForClass | ( | SgTemplateInstantiationMemberFunctionDecl * | memberFunctionInstantiation | ) |
Recursively print current and parent nodes. used within gdb to probe the context of a node.
Definition at line 783 of file sageInterface.C.
References SgClassDefinition::get_declaration(), SgNode::get_parent(), SgStatement::get_scope(), SgTemplateInstantiationDecl::get_templateDeclaration(), and SgTemplateInstantiationMemberFunctionDecl::get_templateDeclaration().
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
Liao, 11/9/2009.
A better version for SgVariableDeclaration::set_baseTypeDefininingDeclaration(), handling all side effects automatically Used to have a struct declaration embedded into a variable declaration
Definition at line 836 of file sageInterface.C.
References SgScopeStatement::generateStatementList(), SgNode::get_parent(), SgStatement::get_scope(), removeStatement(), and SgNode::set_parent().
bool SageInterface::declarationPreceedsDefinition | ( | SgDeclarationStatement * | nonDefiningDeclaration, |
SgDeclarationStatement * | definingDeclaration | ||
) |
Check if a defining declaration comes before of after the non-defining declaration.
Definition at line 6101 of file sageInterface.C.
References SgDeclarationStatement::class_name(), SgDeclarationStatement::get_definingDeclaration(), and SgLocatedNode::get_file_info().
bool SageInterface::functionCallExpressionPreceedsDeclarationWhichAssociatesScope | ( | SgFunctionCallExp * | functionCall | ) |
Recursively print current and parent nodes. used within gdb to probe the context of a node.
Definition at line 6233 of file sageInterface.C.
References SgNode::class_name(), SgExpression::class_name(), SgFunctionCallExp::class_name(), functionCallExpressionPreceedsDeclarationWhichAssociatesScope(), SgLocatedNode::get_file_info(), SgExpression::get_file_info(), SgDeclarationStatement::get_firstNondefiningDeclaration(), SgNode::get_parent(), SgScopeStatement::supportsDefiningFunctionDeclaration(), and SgExpression::variantT().
Referenced by functionCallExpressionPreceedsDeclarationWhichAssociatesScope().
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.
Definition at line 999 of file sageInterface.C.
References get_name(), and SgProject::get_verbose().
Deep copy an arbitrary subtree.
Definition at line 7935 of file sageInterface.C.
References setSourcePositionForTransformation().
Referenced by deepCopy().
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 559 of file sageInterface.h.
References deepCopyNode().
Referenced by copyExpression(), copyStatement(), insertAfterUsingCommaOp(), loopCollapsing(), loopUnrolling(), normalizeArrowExpWithAddressOfLeftOperand(), normalizeForLoopIncrement(), normalizeForLoopInitDeclaration(), normalizeForLoopTest(), replaceWithPattern(), setLoopStride(), and splitVariableDeclaration().
SgExpression * SageInterface::copyExpression | ( | SgExpression * | e | ) |
Deep copy an expression.
Definition at line 13759 of file sageInterface.C.
References deepCopy().
Referenced by SageBuilder::buildEnumVal(), createTempVariableAndReferenceForExpression(), createTempVariableForExpression(), loopCollapsing(), loopTiling(), loopUnrolling(), mergeAssignmentWithDeclaration(), mergeDeclarationWithAssignment(), moveVariableDeclaration(), and normalizeForLoopIncrement().
SgStatement * SageInterface::copyStatement | ( | SgStatement * | s | ) |
Deep copy a statement.
Definition at line 13769 of file sageInterface.C.
References deepCopy().
Referenced by instrumentEndOfFunction().
SgVariableSymbol * SageInterface::getFirstVarSym | ( | SgVariableDeclaration * | decl | ) |
Get the variable symbol for the first initialized name of a declaration stmt.
Definition at line 8498 of file sageInterface.C.
Referenced by SageBuilder::buildOpaqueVarRefExp(), SageBuilder::buildVarRefExp(), insertAfterUsingCommaOp(), loopCollapsing(), moveVariableDeclaration(), normalizeForLoopInitDeclaration(), replaceExpressionWithStatement(), splitExpression(), and unnormalizeForLoopInitDeclaration().
SgInitializedName * SageInterface::getFirstInitializedName | ( | SgVariableDeclaration * | decl | ) |
Get the first initialized name of a declaration statement.
Definition at line 8506 of file sageInterface.C.
References SgVariableDeclaration::get_variables().
Referenced by SageBuilder::buildTemplateVariableDeclaration_nfi(), SageBuilder::buildVariableDeclaration_nfi(), checkForInitializers(), mergeAssignmentWithDeclaration(), mergeDeclarationWithAssignment(), moveVariableDeclaration(), and splitVariableDeclaration().
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.
Definition at line 11541 of file sageInterface.C.
References SgForInitStatement::get_init_stmt(), SgNode::get_parent(), SgBasicBlock::get_statements(), and SgStatement::replace_statement().
Referenced by removeUnusedLabels(), and replaceExpressionWithStatement().
bool SageInterface::isConstantTrue | ( | SgExpression * | e | ) |
Check if a bool or int constant expression evaluates to be a true value.
Definition at line 13711 of file sageInterface.C.
References isConstantFalse(), isConstantTrue(), and SgExpression::variantT().
Referenced by isConstantFalse(), and isConstantTrue().
bool SageInterface::isConstantFalse | ( | SgExpression * | e | ) |
Check if a bool or int constant expression evaluates to be a false value.
Definition at line 13727 of file sageInterface.C.
References isConstantFalse(), isConstantTrue(), and SgExpression::variantT().
Referenced by isConstantFalse(), and isConstantTrue().
bool SageInterface::isCallToParticularFunction | ( | SgFunctionDeclaration * | decl, |
SgExpression * | e | ||
) |
Recursively print current and parent nodes. used within gdb to probe the context of a node.
Definition at line 13738 of file sageInterface.C.
bool SageInterface::isCallToParticularFunction | ( | const std::string & | qualifiedName, |
size_t | arity, | ||
SgExpression * | e | ||
) |
Recursively print current and parent nodes. used within gdb to probe the context of a node.
Definition at line 13747 of file sageInterface.C.
bool SageInterface::isStatic | ( | SgDeclarationStatement * | stmt | ) |
Check if a declaration has a "static' modifier.
Definition at line 18298 of file sageInterface.C.
Referenced by isDataMemberReference(), and isMemberFunctionMemberReference().
void SageInterface::setStatic | ( | SgDeclarationStatement * | stmt | ) |
Set a declaration as static.
Definition at line 18305 of file sageInterface.C.
bool SageInterface::isExtern | ( | SgDeclarationStatement * | stmt | ) |
Check if a declaration has an "extern" modifier.
Definition at line 18311 of file sageInterface.C.
void SageInterface::setExtern | ( | SgDeclarationStatement * | stmt | ) |
Set a declaration as extern.
Definition at line 18319 of file sageInterface.C.
bool SageInterface::isMutable | ( | SgInitializedName * | name | ) |
True if an SgInitializedName is "mutable' (has storage modifier set)
Definition at line 18326 of file sageInterface.C.
Referenced by isJovialOutParam().
bool SageInterface::isJovialOutParam | ( | SgInitializedName * | name | ) |
True if a parameter name is a Jovial output parameter.
Definition at line 18333 of file sageInterface.C.
References isMutable().
Referenced by getInParameters(), and getOutParameters().
std::vector< SgInitializedName * > SageInterface::getInParameters | ( | const SgInitializedNamePtrList & | params | ) |
Get a vector of Jovial input parameters from the function parameter list (may work for Fortran in the future)
Definition at line 18340 of file sageInterface.C.
References isJovialOutParam().
std::vector< SgInitializedName * > SageInterface::getOutParameters | ( | const SgInitializedNamePtrList & | params | ) |
Get a vector of Jovial output parameters from the function parameter list (may work for Fortran in the future)
Definition at line 18352 of file sageInterface.C.
References isJovialOutParam().
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
Return the left hand, right hand expressions and if the left hand variable is also being read. This code is from AstInterface::IsAssignment()
Definition at line 13206 of file sageInterface.C.
References SgBinaryOp::get_lhs_operand(), SgAssignInitializer::get_operand(), SgBinaryOp::get_rhs_operand(), and SgExpression::variantT().
Referenced by getLoopIndexVariable(), and isCanonicalForLoop().
SgInitializedName * SageInterface::convertRefToInitializedName | ( | SgNode * | current, |
bool | coarseGrain = true |
||
) |
Variable references can be introduced by SgVarRef, SgPntrArrRefExp, SgInitializedName, SgMemberFunctionRef etc. For Dot and Arrow Expressions, their lhs is used to obtain SgInitializedName (coarse grain) by default. Otherwise, fine-grain rhs is used.
Variable references can be introduced by SgVarRef, SgPntrArrRefExp, SgInitializedName, SgMemberFunctionRef etc.
This function will convert them all to a top level SgInitializedName. For dot and arrow expressions, a top level SgInitializedName.
Definition at line 21897 of file sageInterface.C.
References SgNode::class_name(), convertRefToInitializedName(), Sg_File_Info::get_col(), SgNode::get_file_info(), Sg_File_Info::get_filename(), SgBinaryOp::get_lhs_operand(), Sg_File_Info::get_line(), SgNode::get_parent(), SgBinaryOp::get_rhs_operand(), getEnclosingFunctionDeclaration(), isArrayReference(), isLambdaCapturedVariable(), and isLambdaFunction().
Referenced by collectReadWriteVariables(), and convertRefToInitializedName().
SgNode * SageInterface::getSgNodeFromAbstractHandleString | ( | const std::string & | input_string | ) |
Obtain a matching SgNode from an abstract handle string.
Definition at line 22046 of file sageInterface.C.
References buildAbstractHandle(), AbstractHandle::abstract_node::getNode(), and getProject().
void SageInterface::dumpInfo | ( | SgNode * | node, |
std::string | desc = "" |
||
) |
Dump information about a SgNode for debugging.
Definition at line 22088 of file sageInterface.C.
References SgNode::class_name(), Sg_File_Info::get_col(), SgLocatedNode::get_file_info(), Sg_File_Info::get_filename(), Sg_File_Info::get_line(), SgVariableSymbol::get_name(), SgInitializedName::get_qualified_name(), and SgLocatedNode::getAttachedPreprocessingInfo().
Referenced by loopCollapsing(), loopTiling(), and loopUnrolling().
vector< SgDeclarationStatement * > SageInterface::sortSgNodeListBasedOnAppearanceOrderInSource | ( | const std::vector< SgDeclarationStatement * > & | nodevec | ) |
Reorder a list of declaration statements based on their appearance order in source files.
Definition at line 19044 of file sageInterface.C.
References SgDeclarationStatement::get_definingDeclaration(), SgDeclarationStatement::get_firstNondefiningDeclaration(), and getProject().
Referenced by getDependentDeclarations().
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.
Definition at line 19177 of file sageInterface.C.
References SgExpression::class_name(), SgFunctionRefExp::getAssociatedFunctionDeclaration(), SgMemberFunctionRefExp::getAssociatedMemberFunctionDeclaration(), and isPrefixOperatorName().
Referenced by isPostfixOperator().
bool SageInterface::isPrefixOperatorName | ( | const SgName & | functionName | ) |
Check for proper names of possible prefix operators (used in isPrefixOperator()).
Definition at line 19151 of file sageInterface.C.
Referenced by isPrefixOperator().
bool SageInterface::isPostfixOperator | ( | SgExpression * | exp | ) |
Is an overloaded operator a postfix operator. (e.g. ).
Definition at line 19270 of file sageInterface.C.
References isIndexOperator(), and isPrefixOperator().
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[]()).
Is an overloaded operator an index operator (also refereded to as call or subscript operators). (e.g. X & operator()() or X & operator[]()).
Definition at line 19278 of file sageInterface.C.
References SgMemberFunctionRefExp::getAssociatedMemberFunctionDeclaration().
Referenced by isPostfixOperator().
SgStatement * SageInterface::lastStatementOfScopeWithTokenInfo | ( | SgScopeStatement * | scope, |
std::map< SgNode *, TokenStreamSequenceToNodeMapping * > & | tokenStreamSequenceMap | ||
) |
Used to support token unparsing (when the output the trailing token sequence).
Definition at line 19312 of file sageInterface.C.
References SgStatement::class_name(), SgScopeStatement::class_name(), SgScopeStatement::generateStatementList(), SgIfStmt::get_false_body(), and SgIfStmt::get_true_body().
void SageInterface::checkAccessPermissions | ( | SgNode * | astNode | ) |
Recursively print current and parent nodes. used within gdb to probe the context of a node.
Definition at line 19371 of file sageInterface.C.
References SgDeclarationStatement::class_name(), SgDeclarationStatement::get_definingDeclaration(), SgDeclarationStatement::get_firstNondefiningDeclaration(), and get_name().
void SageInterface::checkSymbolTables | ( | SgNode * | astNode | ) |
Recursively print current and parent nodes. used within gdb to probe the context of a node.
Definition at line 19424 of file sageInterface.C.
References SgFunctionDefinition::get_body(), SgNamespaceDeclarationStatement::get_name(), SgScopeStatement::get_symbol_table(), and SgSymbolTable::print().
void SageInterface::markSubtreeToBeUnparsed | ( | SgNode * | root, |
int | physical_file_id | ||
) |
Recursively print current and parent nodes. used within gdb to probe the context of a node.
Definition at line 19564 of file sageInterface.C.
References RoseAst::begin(), RoseAst::end(), and markNodeToBeUnparsed().
Referenced by addDefaultConstructorIfRequired().
void SageInterface::markNodeToBeUnparsed | ( | SgNode * | node, |
int | physical_file_id | ||
) |
Recursively print current and parent nodes. used within gdb to probe the context of a node.
Definition at line 19488 of file sageInterface.C.
References SgNode::class_name(), SgLocatedNode::class_name(), SgLocatedNode::get_file_info(), SgNode::get_file_info(), Sg_File_Info::setOutputInCodeGeneration(), SgLocatedNode::setOutputInCodeGeneration(), Sg_File_Info::setTransformation(), and SgLocatedNode::setTransformation().
Referenced by markSubtreeToBeUnparsed(), and markSubtreeToBeUnparsedTreeTraversal().
void SageInterface::markSubtreeToBeUnparsedTreeTraversal | ( | SgNode * | root, |
int | physical_file_id | ||
) |
Recursively print current and parent nodes. used within gdb to probe the context of a node.
Definition at line 19575 of file sageInterface.C.
References SgNode::class_name(), and markNodeToBeUnparsed().
bool SageInterface::findFirstSgCastExpMarkedAsTransformation | ( | SgNode * | n, |
const std::string & | s | ||
) |
Recursively print current and parent nodes. used within gdb to probe the context of a node.
Definition at line 27568 of file sageInterface.C.
References SgNode::class_name(), SgExpression::get_file_info(), SgNode::get_parent(), and Sg_File_Info::isTransformation().
|
inline |
Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!
Definition at line 695 of file sageInterface.h.
Referenced by attachComment(), SageBuilder::buildTypedefDeclaration_nfi(), fixLabelStatement(), and setParameterList().
|
inline |
Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!
Definition at line 696 of file sageInterface.h.
Referenced by attachComment(), is_mixed_C_and_Cxx_language(), is_mixed_Fortran_and_C_and_Cxx_language(), is_mixed_Fortran_and_C_language(), isSameFunction(), and moveCommentsToNewStatement().
|
inline |
Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!
Definition at line 697 of file sageInterface.h.
|
inline |
Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!
Definition at line 698 of file sageInterface.h.
|
inline |
Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!
Definition at line 699 of file sageInterface.h.
|
inline |
Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!
Definition at line 700 of file sageInterface.h.
Referenced by attachComment(), isSameFunction(), and moveCommentsToNewStatement().
|
inline |
Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!
Definition at line 701 of file sageInterface.h.
Referenced by attachComment(), collectUseByAddressVariableRefs(), is_mixed_C_and_Cxx_language(), is_mixed_Fortran_and_C_and_Cxx_language(), is_mixed_Fortran_and_Cxx_language(), isSameFunction(), isUseByAddressVariableRef(), and moveCommentsToNewStatement().
|
inline |
Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!
Definition at line 702 of file sageInterface.h.
Referenced by attachComment(), isMain(), and isSameFunction().
|
inline |
Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!
Definition at line 703 of file sageInterface.h.
Referenced by attachComment(), SageBuilder::buildFunctionRefExp(), and language_may_contain_nondeclarations_in_scope().
|
inline |
Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!
Definition at line 704 of file sageInterface.h.
|
inline |
Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!
Definition at line 705 of file sageInterface.h.
Referenced by attachComment(), SageBuilder::buildFunctionRefExp(), SageBuilder::buildGotoStatement(), SageBuilder::buildIfStmt(), SageBuilder::buildLabelStatement(), SageBuilder::buildNondefiningFunctionDeclaration(), SageBuilder::buildVariableDeclaration(), fixVariableDeclaration(), is_mixed_Fortran_and_C_and_Cxx_language(), is_mixed_Fortran_and_C_language(), is_mixed_Fortran_and_Cxx_language(), isMain(), isSameFunction(), language_may_contain_nondeclarations_in_scope(), and suggestNextNumericLabel().
|
inline |
Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!
Definition at line 706 of file sageInterface.h.
Referenced by attachComment().
|
inline |
Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!
Definition at line 707 of file sageInterface.h.
Referenced by isSameFunction().
|
inline |
Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!
Definition at line 708 of file sageInterface.h.
Referenced by isSameFunction(), and language_may_contain_nondeclarations_in_scope().
|
inline |
Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!
Definition at line 709 of file sageInterface.h.
Referenced by isSameFunction().
|
inline |
Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!
Definition at line 710 of file sageInterface.h.
Referenced by isSameFunction().
|
inline |
Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!
Definition at line 711 of file sageInterface.h.
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!
Definition at line 5726 of file sageInterface.C.
References is_C_language(), and is_Cxx_language().
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!
Definition at line 5731 of file sageInterface.C.
References is_C_language(), and is_Fortran_language().
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!
Definition at line 5736 of file sageInterface.C.
References is_Cxx_language(), and is_Fortran_language().
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!
Definition at line 5741 of file sageInterface.C.
References is_C_language(), is_Cxx_language(), and is_Fortran_language().
bool SageInterface::is_language_case_insensitive | ( | ) |
Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!
Definition at line 5746 of file sageInterface.C.
References SageBuilder::symbol_table_case_insensitive_semantics.
Referenced by SageBuilder::buildBasicBlock(), SageBuilder::buildBasicBlock_nfi(), SageBuilder::buildClassDefinition(), SageBuilder::buildClassDefinition_nfi(), SageBuilder::buildDefiningFunctionDeclaration_T(), SageBuilder::buildForStatement(), SageBuilder::buildForStatement_nfi(), SageBuilder::buildForStatement_nfi(), SageBuilder::buildFortranDo(), SageBuilder::buildFortranDo_nfi(), SageBuilder::buildIfStmt(), SageBuilder::buildJovialForThenStatement_nfi(), SageBuilder::buildSwitchStatement(), SageBuilder::buildTemplateClassDefinition(), SageBuilder::buildUpcForAllStatement_nfi(), SageBuilder::buildWhileStmt(), initializeIfStmt(), initializeSwitchStatement(), and initializeWhileStatement().
bool SageInterface::language_may_contain_nondeclarations_in_scope | ( | ) |
Brief These traverse the memory pool of SgFile IR nodes and determine what languages are in use!
Definition at line 5753 of file sageInterface.C.
References is_Fortran_language(), is_Jovial_language(), and is_Python_language().
Referenced by SageBuilder::buildDefiningFunctionDeclaration_T().
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).
Definition at line 5778 of file sageInterface.C.
References SgScopeStatement::class_name().
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).
Definition at line 5761 of file sageInterface.C.
SgNamespaceDefinitionStatement * SageInterface::enclosingNamespaceScope | ( | SgDeclarationStatement * | declaration | ) |
Find the enclosing namespace of a declaration.
Definition at line 751 of file sageInterface.C.
References SgScopeStatement::class_name(), get_name(), and SgStatement::get_scope().
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).
Definition at line 869 of file sageInterface.C.
References SgScopeStatement::containsOnlyDeclarations(), get_name(), SgFunctionDeclaration::get_scope(), SgScopeStatement::getDeclarationList(), and SgDeclarationStatement::isForward().
check if node1 is a strict ancestor of node 2. (a node is not considered its own ancestor)
Definition at line 937 of file sageInterface.C.
References SgNode::get_parent().
Referenced by moveCommentsToNewStatement(), and ReductionRecognition().
void SageInterface::dumpPreprocInfo | ( | SgLocatedNode * | locatedNode | ) |
Dumps a located node's preprocessing information.
Definition at line 17180 of file sageInterface.C.
References SgLocatedNode::class_name(), SgLocatedNode::get_file_info(), SgLocatedNode::getAttachedPreprocessingInfo(), and SgLocatedNode::sage_class_name().
PreprocessingInfo * SageInterface::findHeader | ( | SgSourceFile * | source_file, |
const std::string & | header_file_name, | ||
bool | isSystemHeader | ||
) |
Find the preprocessingInfo node representing #include <header.h> or #include "header.h" within a source file. Return NULL if not found.
Definition at line 16216 of file sageInterface.C.
References SgGlobal::get_declarations(), and SgLocatedNode::getAttachedPreprocessingInfo().
PreprocessingInfo * SageInterface::insertHeader | ( | SgSourceFile * | source_file, |
const std::string & | header_file_name, | ||
bool | isSystemHeader, | ||
bool | asLastHeader | ||
) |
Insert #include "filename" or #include <filename> (system header) onto the global scope of a source file, add to be the last #include .. by default among existing headers, Or as the first header. Recommended for use.
Definition at line 16667 of file sageInterface.C.
References SgLocatedNode::addToAttachedPreprocessingInfo(), SgGlobal::get_declarations(), SgLocatedNode::get_file_info(), insertHeader(), and Sg_File_Info::setTransformation().
Referenced by insertHeader().
void SageInterface::insertHeader | ( | SgStatement * | stmt, |
PreprocessingInfo * | newheader, | ||
bool | asLastHeader | ||
) |
Insert a new header right before stmt, if there are existing headers attached to stmt, insert it as the last or first header as specified by asLastHeader.
Definition at line 16550 of file sageInterface.C.
References SgLocatedNode::addToAttachedPreprocessingInfo(), and SgLocatedNode::getAttachedPreprocessingInfo().
PreprocessingInfo * SageInterface::insertHeader | ( | SgSourceFile * | source_file, |
const std::string & | header_file_name, | ||
bool | isSystemHeader = false , |
||
PreprocessingInfo::RelativePositionType | position = PreprocessingInfo::before |
||
) |
Insert #include "filename" or #include <filename> (system header) onto the global scope of a source file.
Definition at line 16269 of file sageInterface.C.
References SgLocatedNode::addToAttachedPreprocessingInfo(), SageBuilder::buildEmptyDeclaration(), SgLocatedNode::get_endOfConstruct(), SgLocatedNode::get_startOfConstruct(), and Sg_File_Info::setTransformation().
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.
Definition at line 16348 of file sageInterface.C.
References SgLocatedNode::addToAttachedPreprocessingInfo(), SageBuilder::buildEmptyDeclaration(), SgDeclarationStatement::class_name(), SgGlobal::get_declarations(), SgLocatedNode::get_file_info(), Sg_File_Info::get_filename(), SgLocatedNode::get_startOfConstruct(), getEnclosingSourceFile(), getGlobalScope(), SgStatement::insert_statement(), Sg_File_Info::setTransformation(), and SageBuilder::topScopeStack().
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.
Definition at line 17078 of file sageInterface.C.
References movePreprocessingInfo().
Referenced by replaceStatement().
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.
Definition at line 16884 of file sageInterface.C.
References SgLocatedNode::addToAttachedPreprocessingInfo(), SgStatement::class_name(), SgDeclarationStatement::get_definingDeclaration(), SgDeclarationStatement::get_firstNondefiningDeclaration(), SgNode::get_isModified(), SgLocatedNode::getAttachedPreprocessingInfo(), SgLocatedNode::insertToAttachedPreprocessingInfo(), printOutComments(), and SgNode::set_isModified().
Referenced by insertStatementBeforeFirstNonDeclaration(), mergeAssignmentWithDeclaration(), mergeDeclarationWithAssignment(), moveUpPreprocessingInfo(), replaceDefiningFunctionDeclarationWithFunctionPrototype(), and replaceStatement().
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.
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 only need to be known until the paste action.
Definition at line 17109 of file sageInterface.C.
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()
Cut preprocessing information from a source node and save it into a buffer. Used in combination of pastePreprocessingInfo()
Definition at line 17152 of file sageInterface.C.
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.
Attach an arbitrary string to a located node. A workaround to insert irregular statements or vendor-specific attributes. We abuse CpreprocessorDefineDeclaration for this purpose.
Definition at line 16757 of file sageInterface.C.
References Sg_File_Info::setTransformation().
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.
Check if a target node has MacroCall attached, if yes, replace them with expanded strings.
Definition at line 16789 of file sageInterface.C.
References SageBuilder::buildPragma().
PreprocessingInfo * SageInterface::attachComment | ( | SgSourceFile * | source_file, |
const std::string & | content, | ||
PreprocessingInfo::DirectiveType | directive_type = PreprocessingInfo::C_StyleComment , |
||
PreprocessingInfo::RelativePositionType | position = PreprocessingInfo::before |
||
) |
Build and attach comment onto the global scope of a source file.
Definition at line 16067 of file sageInterface.C.
References SgLocatedNode::addToAttachedPreprocessingInfo(), and Sg_File_Info::setTransformation().
Referenced by SageBuilder::buildComment(), and loopUnrolling().
PreprocessingInfo * SageInterface::attachComment | ( | 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.
Definition at line 16087 of file sageInterface.C.
References is_Ada_language(), is_C99_language(), is_C_language(), is_CAF_language(), is_Cxx_language(), is_Fortran_language(), is_Java_language(), is_Jovial_language(), and Sg_File_Info::setTransformation().
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.
Definition at line 6609 of file sageInterface.C.
References SgNode::addNewAttribute(), SgNode::attributeExists(), and SgNode::getAttribute().
void SageInterface::guardNode | ( | SgLocatedNode * | target, |
std::string | guard | ||
) |
Add preproccessor guard around a given node.
It surrounds the node with "#if guard" and "#endif"
Definition at line 16186 of file sageInterface.C.
References Sg_File_Info::setTransformation().
int SageInterface::moveUpInnerDanglingIfEndifDirective | ( | SgLocatedNode * | lnode | ) |
Extract sequences like " #endif #endif ... #if | #ifdef| #ifndef" buried inside subtree of lnode.
Definition at line 27813 of file sageInterface.C.
References SgLocatedNode::addToAttachedPreprocessingInfo(), RoseAst::begin(), RoseAst::end(), eraseNullPreprocessingInfo(), SgLocatedNode::getAttachedPreprocessingInfo(), and preOrderCollectPreprocessingInfo().
Referenced by removeStatement(), and replaceStatement().
int SageInterface::eraseNullPreprocessingInfo | ( | SgLocatedNode * | lnode | ) |
Dumps a located node's preprocessing information.
Definition at line 27691 of file sageInterface.C.
References RoseAst::begin(), RoseAst::end(), and SgLocatedNode::getAttachedPreprocessingInfo().
Referenced by moveUpInnerDanglingIfEndifDirective().
void SageInterface::preOrderCollectPreprocessingInfo | ( | SgNode * | current, |
std::vector< PreprocessingInfo * > & | infoList, | ||
int | depth | ||
) |
Dumps a located node's preprocessing information.
Definition at line 27744 of file sageInterface.C.
References SgNode::get_traversalSuccessorContainer(), and preOrderCollectPreprocessingInfo().
Referenced by moveUpInnerDanglingIfEndifDirective(), and preOrderCollectPreprocessingInfo().
void SageInterface::setSourcePositionAtRootAndAllChildren | ( | SgNode * | root | ) |
Set the source code positon for the subtree (including the root).
Definition at line 7439 of file sageInterface.C.
References setSourcePosition().
Referenced by SageBuilder::buildAssignStatement(), SageBuilder::buildDefiningFunctionDeclaration_T(), SageBuilder::buildFunctionParameterTypeList(), SageBuilder::buildFunctionParameterTypeList(), SageBuilder::buildInitializedName(), SageBuilder::buildVariableDeclaration(), and setSourcePositionForTransformation().
void SageInterface::setSourcePositionAsTransformation | ( | SgNode * | node | ) |
DQ (5/1/2012): New function with improved name.
Definition at line 7258 of file sageInterface.C.
References Sg_File_Info::generateDefaultFileInfoForTransformationNode(), SgLocatedNode::get_endOfConstruct(), SgPragma::get_startOfConstruct(), SgLocatedNode::get_startOfConstruct(), SgLocatedNode::set_endOfConstruct(), SgNode::set_parent(), and SgLocatedNode::set_startOfConstruct().
Referenced by setSourcePosition().
void SageInterface::setSourcePositionPointersToNull | ( | SgNode * | node | ) |
Set the source code positon for the current (input) node.
Definition at line 7328 of file sageInterface.C.
References SgLocatedNode::get_endOfConstruct(), SgPragma::get_startOfConstruct(), SgLocatedNode::get_startOfConstruct(), SgLocatedNode::set_endOfConstruct(), and SgLocatedNode::set_startOfConstruct().
Referenced by setSourcePosition().
void SageInterface::setOneSourcePositionNull | ( | SgNode * | node | ) |
Set current node's source position as NULL.
Definition at line 7316 of file sageInterface.C.
References setSourcePosition().
Referenced by SageBuilder::buildActualArgumentExpression_nfi(), SageBuilder::buildAggregateInitializer_nfi(), SageBuilder::buildAlignOfOp_nfi(), SageBuilder::buildAlignOfOp_nfi(), SageBuilder::buildAsmStatement_nfi(), SageBuilder::buildAssertStmt_nfi(), SageBuilder::buildAwaitExpression_nfi(), SageBuilder::buildBasicBlock_nfi(), SageBuilder::buildBoolValExp_nfi(), SageBuilder::buildBracedInitializer_nfi(), SageBuilder::buildBreakStmt_nfi(), SageBuilder::buildCaseOptionStmt_nfi(), SageBuilder::buildCastExp_nfi(), SageBuilder::buildChar16Val_nfi(), SageBuilder::buildChar32Val_nfi(), SageBuilder::buildCharVal_nfi(), SageBuilder::buildChooseExpression_nfi(), SageBuilder::buildClassDefinition_nfi(), SageBuilder::buildClassExp_nfi(), SageBuilder::buildClassNameRefExp_nfi(), SageBuilder::buildColonShapeExp_nfi(), SageBuilder::buildComplexVal_nfi(), SageBuilder::buildCompoundInitializer_nfi(), SageBuilder::buildCompoundLiteralExp_nfi(), SageBuilder::buildComprehension_nfi(), SageBuilder::buildConditionalExp_nfi(), SageBuilder::buildConstructorInitializer_nfi(), SageBuilder::buildContinueStmt_nfi(), SageBuilder::buildCtorInitializerList_nfi(), SageBuilder::buildCudaKernelCallExp_nfi(), SageBuilder::buildCudaKernelExecConfig_nfi(), SageBuilder::buildDefaultOptionStmt_nfi(), SageBuilder::buildDeleteExp_nfi(), SageBuilder::buildDictionaryComprehension_nfi(), SageBuilder::buildDictionaryExp_nfi(), SageBuilder::buildDoubleVal_nfi(), SageBuilder::buildDoWhileStatement_nfi(), SageBuilder::buildDoWhileStmt_nfi(), SageBuilder::buildEnumDeclaration_nfi(), SageBuilder::buildEnumVal_nfi(), SageBuilder::buildExecStatement_nfi(), SageBuilder::buildExprListExp_nfi(), SageBuilder::buildExprListExp_nfi(), SageBuilder::buildExprStatement_nfi(), SageBuilder::buildFloat128Val_nfi(), SageBuilder::buildFloat80Val_nfi(), SageBuilder::buildFloatVal_nfi(), SageBuilder::buildFloatVal_nfi(), SageBuilder::buildFoldExpression_nfi(), SageBuilder::buildForStatement_nfi(), SageBuilder::buildForStatement_nfi(), SageBuilder::buildFortranContinueStmt_nfi(), SageBuilder::buildFortranDo_nfi(), SageBuilder::buildFunctionCallExp_nfi(), SageBuilder::buildFunctionParameterList_nfi(), SageBuilder::buildFunctionParameterRefExp_nfi(), SageBuilder::buildFunctionRefExp_nfi(), SageBuilder::buildGotoStatement_nfi(), SageBuilder::buildGotoStatement_nfi(), SageBuilder::buildImaginaryVal_nfi(), SageBuilder::buildInitializedName_nfi(), SageBuilder::buildIntVal_nfi(), SageBuilder::buildIntVal_nfi(), SageBuilder::buildJovialBitVal_nfi(), SageBuilder::buildJovialForThenStatement_nfi(), SageBuilder::buildKeyDatumPair_nfi(), SageBuilder::buildLambdaCapture_nfi(), SageBuilder::buildLambdaCaptureList_nfi(), SageBuilder::buildLambdaExp_nfi(), SageBuilder::buildListComprehension(), SageBuilder::buildListExp_nfi(), SageBuilder::buildLongDoubleVal_nfi(), SageBuilder::buildLongIntVal_nfi(), SageBuilder::buildLongLongIntVal_nfi(), SageBuilder::buildMemberFunctionRefExp_nfi(), SageBuilder::buildNamespaceDeclaration_nfi(), SageBuilder::buildNaryBooleanOp_nfi(), SageBuilder::buildNaryComparisonOp_nfi(), SageBuilder::buildNoexceptOp_nfi(), SageBuilder::buildNondefiningClassDeclaration_nfi(), SageBuilder::buildNondefiningEnumDeclaration_nfi(), SageBuilder::buildNonrealRefExp_nfi(), SageBuilder::buildNullExpression_nfi(), SageBuilder::buildNullptrValExp_nfi(), SageBuilder::buildNullStatement_nfi(), SageBuilder::buildPassStatement_nfi(), SageBuilder::buildPythonGlobalStmt_nfi(), SageBuilder::buildPythonPrintStmt_nfi(), SageBuilder::buildRangeBasedForStatement_nfi(), SageBuilder::buildReturnStmt_nfi(), SageBuilder::buildSetComprehension_nfi(), SageBuilder::buildShortVal_nfi(), SageBuilder::buildSizeOfOp_nfi(), SageBuilder::buildSizeOfOp_nfi(), SageBuilder::buildStatementExpression_nfi(), SageBuilder::buildStmtDeclarationStatement_nfi(), SageBuilder::buildStringConversion_nfi(), SageBuilder::buildStringVal_nfi(), SageBuilder::buildSuperExp_nfi(), SageBuilder::buildSwitchStatement_nfi(), SageBuilder::buildTemplateFunctionRefExp_nfi(), SageBuilder::buildTemplateInstantiationTypedefDeclaration_nfi(), SageBuilder::buildTemplateMemberFunctionRefExp_nfi(), SageBuilder::buildTemplateParameterVal_nfi(), SageBuilder::buildTemplateTypedefDeclaration_nfi(), SageBuilder::buildTemplateVariableDeclaration_nfi(), SageBuilder::buildThisExp_nfi(), SageBuilder::buildTupleExp_nfi(), SageBuilder::buildTypedefDeclaration_nfi(), SageBuilder::buildUnsignedCharVal_nfi(), SageBuilder::buildUnsignedIntVal_nfi(), SageBuilder::buildUnsignedLongLongIntVal_nfi(), SageBuilder::buildUnsignedLongVal_nfi(), SageBuilder::buildUnsignedShortVal_nfi(), SageBuilder::buildUpcBarrierStatement_nfi(), SageBuilder::buildUpcFenceStatement_nfi(), SageBuilder::buildUpcForAllStatement_nfi(), SageBuilder::buildUpcForAllStatement_nfi(), SageBuilder::buildUpcMythread_nfi(), SageBuilder::buildUpcNotifyStatement_nfi(), SageBuilder::buildUpcThreads_nfi(), SageBuilder::buildUpcWaitStatement_nfi(), SageBuilder::buildVarArgOp_nfi(), SageBuilder::buildVariableDeclaration_nfi(), SageBuilder::buildVarRefExp_nfi(), SageBuilder::buildVoidVal_nfi(), SageBuilder::buildWcharVal_nfi(), SageBuilder::buildWhileStmt_nfi(), SageBuilder::buildWithStatement_nfi(), SageBuilder::buildYieldExpression_nfi(), initializeIfStmt(), and initializeWhileStatement().
void SageInterface::setSourcePositionForTransformation | ( | SgNode * | root | ) |
Recursively set source position info(Sg_File_Info) as transformation generated.
Definition at line 7387 of file sageInterface.C.
References setOneSourcePositionForTransformation(), and setSourcePositionAtRootAndAllChildren().
Referenced by SageBuilder::buildNondefiningTemplateClassDeclaration(), SageBuilder::buildTemplateClassDeclaration(), deepCopyNode(), and loopInterchange().
bool SageInterface::insideSystemHeader | ( | SgLocatedNode * | node | ) |
Set source position info(Sg_File_Info) as transformation generated for all SgNodes in memory pool.
Check if a node is from a system header file
Definition at line 25699 of file sageInterface.C.
References SgLocatedNode::get_file_info().
bool SageInterface::insideHeader | ( | SgLocatedNode * | node | ) |
Check if a node is from a header file.
Definition at line 25726 of file sageInterface.C.
References SgLocatedNode::class_name(), Sg_File_Info::get_col(), SgLocatedNode::get_file_info(), and Sg_File_Info::get_line().
Get the right bool type according to C or C++ language input.
Definition at line 7950 of file sageInterface.C.
References SgTypeInt::createType(), SgTypeBool::createType(), and SgFile::e_C_language.
Referenced by replaceExpressionWithStatement().
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.
Referenced by isCanonicalDoLoop(), and isCanonicalForLoop().
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::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::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
Referenced by ReductionRecognition().
std::vector< SgExpression * > SageInterface::get_C_array_dimensions | ( | const SgArrayType & | arrtype | ) |
returns the array dimensions in an array as defined for arrtype
arrtype | the type of a C/C++ array |
Definition at line 23281 of file sageInterface.C.
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
arrtype | the type of a C/C++ array |
varref | a reference to an array variable (the variable of type arrtype) |
Definition at line 23287 of file sageInterface.C.
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.
Definition at line 23293 of file sageInterface.C.
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.
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.
Definition at line 6672 of file sageInterface.C.
References SgSymbol::get_type(), lookupSymbolInParentScopes(), and SageBuilder::topScopeStack().
bool SageInterface::templateArgumentEquivalence | ( | SgTemplateArgument * | arg1, |
SgTemplateArgument * | arg2 | ||
) |
Verify that 2 SgTemplateArgument are equivalent (same type, same expression, or same template declaration)
Definition at line 7983 of file sageInterface.C.
References SgTemplateArgument::argument_undefined, SgType::class_name(), SgExpression::class_name(), SgTemplateArgument::get_argumentType(), SgTemplateArgument::get_expression(), SgTemplateArgument::get_type(), isEquivalentType(), SgTemplateArgument::nontype_argument, SgTemplateArgument::start_of_pack_expansion_argument, SgTemplateArgument::template_template_argument, SgTemplateArgument::type_argument, and SgExpression::variantT().
Referenced by templateArgumentListEquivalence().
bool SageInterface::templateArgumentListEquivalence | ( | const SgTemplateArgumentPtrList & | list1, |
const SgTemplateArgumentPtrList & | list2 | ||
) |
Verify that 2 SgTemplateArgumentPtrList are equivalent.
Definition at line 8115 of file sageInterface.C.
References templateArgumentEquivalence().
Referenced by SageBuilder::buildDefiningFunctionDeclaration_T().
Test for equivalence of types independent of access permissions (private or protected modes for members of classes).
Definition at line 25819 of file sageInterface.C.
References SgNode::class_name(), SgType::class_name(), SgNonrealType::get_name(), SgNode::get_parent(), SgModifierType::get_typeModifier(), SgType::getInternalTypes(), isEquivalentType(), SgType::stripType(), SgNode::unparseToString(), and SgType::variantT().
Referenced by isEquivalentFunctionType(), isEquivalentType(), and templateArgumentEquivalence().
SgFunctionType * SageInterface::findFunctionType | ( | SgType * | return_type, |
SgFunctionParameterTypeList * | typeList | ||
) |
Find the function type matching a function signature plus a given return type.
Definition at line 25761 of file sageInterface.C.
References SgNode::get_globalFunctionTypeTable(), and SgFunctionType::get_mangled().
Referenced by SageBuilder::buildNondefiningFunctionDeclaration().
bool SageInterface::isEquivalentFunctionType | ( | const SgFunctionType * | lhs, |
const SgFunctionType * | rhs | ||
) |
Test if two types are equivalent SgFunctionType nodes.
This is necessary for template function types They may differ in one SgTemplateType pointer but identical otherwise.
This is necessary for template function types They may differ in one SgTemplateType pointer but identical otherwise. The algorithm is to compare return type and all argument types
Definition at line 25779 of file sageInterface.C.
References SgFunctionType::get_arguments(), and isEquivalentType().
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++;}
Definition at line 8166 of file sageInterface.C.
References appendStatement(), SageBuilder::buildBasicBlock(), SageBuilder::buildLabelStatement(), changeContinuesToGotos(), gensym_counter, getEnclosingProcedure(), getLoopBody(), and setLoopBody().
Referenced by moveForStatementIncrementIntoBody(), and replaceExpressionWithStatement().
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++;}
Definition at line 8184 of file sageInterface.C.
References addStepToLoopBody(), SageBuilder::buildExprStatement(), SageBuilder::buildNullExpression(), and SgNode::set_parent().
Referenced by convertForToWhile().
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++;}
Definition at line 8209 of file sageInterface.C.
References appendStatement(), SageBuilder::buildBasicBlock(), SageBuilder::buildBoolValExp(), SageBuilder::buildExprStatement(), SageBuilder::buildWhileStmt(), SgForStatement::get_for_init_stmt(), SgForInitStatement::get_init_stmt(), SgForStatement::get_loop_body(), SgNode::get_parent(), SgBasicBlock::get_statements(), moveForStatementIncrementIntoBody(), and SgStatement::replace_statement().
Referenced by convertAllForsToWhiles().
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++;}
Definition at line 8229 of file sageInterface.C.
References convertForToWhile().
void SageInterface::changeContinuesToGotos | ( | SgStatement * | stmt, |
SgLabelStatement * | label | ||
) |
Change continue statements in a given block of code to gotos to a label.
Definition at line 7961 of file sageInterface.C.
References SageBuilder::buildGotoStatement(), and findContinueStmts().
Referenced by addStepToLoopBody().
SgInitializedName * SageInterface::getLoopIndexVariable | ( | SgNode * | loop | ) |
Return the loop index variable for a for loop.
Return the loop index variable for a C/C++ for or Fortran Do loop.
Definition at line 12495 of file sageInterface.C.
References SgStatement::class_name(), SgLocatedNode::get_file_info(), SgBinaryOp::get_lhs_operand(), SgVariableDeclaration::get_variables(), isAssignmentStatement(), and SgNode::unparseToString().
Referenced by isLoopIndexVariable().
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.
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 to find all enclosing loops and check if ivar is used as an index for either of them.
Definition at line 12592 of file sageInterface.C.
References findEnclosingLoop(), SgNode::get_parent(), getEnclosingStatement(), and getLoopIndexVariable().
bool SageInterface::hasMultipleInitStatmentsOrExpressions | ( | SgForStatement * | loop | ) |
Check if a for loop uses C99 style initialization statement with multiple expressions like for (int i=0, j=0; ..) or for (i=0,j=0;...)
for (int i=0, j=0; ..) is stored as two variable declarations under SgForInitStatement's init_stmt member for (i=0,j=0;...) is stored as a single expression statement, with comma expression (i=0,j=0).
Definition at line 12619 of file sageInterface.C.
SgStatement * SageInterface::getLoopBody | ( | SgScopeStatement * | loop | ) |
Routines to get and set the body of a loop.
Definition at line 11621 of file sageInterface.C.
References SgWhileStmt::get_body(), SgDoWhileStmt::get_body(), and SgForStatement::get_loop_body().
Referenced by addStepToLoopBody(), and changeBreakStatementsToGotos().
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++;}
Definition at line 11630 of file sageInterface.C.
References SgWhileStmt::set_body(), SgDoWhileStmt::set_body(), SgForStatement::set_loop_body(), and SgNode::set_parent().
Referenced by addStepToLoopBody().
SgStatement * SageInterface::getLoopCondition | ( | SgScopeStatement * | loop | ) |
Routines to get the condition of a loop. It recognize While-loop, For-loop, and Do-While-loop.
Definition at line 11643 of file sageInterface.C.
References SgWhileStmt::get_condition(), and SgDoWhileStmt::get_condition().
void SageInterface::setLoopCondition | ( | SgScopeStatement * | loop, |
SgStatement * | cond | ||
) |
Set the condition statement of a loop, including While-loop, For-loop, and Do-While-loop.
Definition at line 11652 of file sageInterface.C.
References SgWhileStmt::set_condition(), SgDoWhileStmt::set_condition(), and SgNode::set_parent().
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.
Based on AstInterface::IsFortranLoop() and ASTtools::getLoopIndexVar()
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
Definition at line 12824 of file sageInterface.C.
References SageBuilder::buildIntVal(), SgBinaryOp::get_lhs_operand(), SgForStatement::get_loop_body(), SgAssignInitializer::get_operand(), SgBinaryOp::get_rhs_operand(), SgInitializedName::get_symbol_from_symbol_table(), SgForStatement::get_test_expr(), SgVariableDeclaration::get_variables(), isAssignmentStatement(), isStrictIntegerType(), SgExpression::variantT(), and SgBinaryOp::variantT().
Referenced by loopCollapsing(), loopTiling(), loopUnrolling(), and ReductionRecognition().
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.
Get Fortran Do loop's key features.
Definition at line 12643 of file sageInterface.C.
References SageBuilder::buildIntVal(), SgBinaryOp::get_lhs_operand(), SgBinaryOp::get_rhs_operand(), SgInitializedName::get_symbol_from_symbol_table(), isStrictIntegerType(), SgExpression::variantT(), and SgBinaryOp::variantT().
void SageInterface::setLoopLowerBound | ( | SgNode * | loop, |
SgExpression * | lb | ||
) |
Set the lower bound of a loop header for (i=lb; ...)
Set the lower bound of a loop header.
Definition at line 13006 of file sageInterface.C.
References SgNode::class_name(), SgExpression::get_lvalue(), SgBinaryOp::get_rhs_operand(), SgExpression::set_lvalue(), SgNode::set_parent(), and SgBinaryOp::set_rhs_operand().
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, ...)
Definition at line 13061 of file sageInterface.C.
References SgNode::class_name(), SgNode::set_parent(), and SgBinaryOp::set_rhs_operand().
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)
Definition at line 13091 of file sageInterface.C.
References SageBuilder::buildPlusAssignOp(), SgNode::class_name(), deepCopy(), SgBinaryOp::get_lhs_operand(), SgVariableSymbol::get_name(), SgUnaryOp::get_operand(), SgNode::get_parent(), SgBinaryOp::get_rhs_operand(), SgBinaryOp::set_lhs_operand(), SgNode::set_parent(), and SgBinaryOp::set_rhs_operand().
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.
Promote 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.
Definition at line 11681 of file sageInterface.C.
References SageBuilder::buildAssignStatement(), SageBuilder::buildVariableDeclaration(), SageBuilder::buildVarRefExp(), deepCopy(), gensym_counter, SgFunctionDefinition::get_body(), SgForStatement::get_for_init_stmt(), SgAssignInitializer::get_operand(), SgVariableDeclaration::get_variables(), getEnclosingFunctionDefinition(), getFirstVarSym(), lookupVariableSymbolInParentScopes(), prependStatement(), removeStatement(), and SgNode::set_parent().
Referenced by forLoopNormalization().
bool SageInterface::unnormalizeForLoopInitDeclaration | ( | SgForStatement * | loop | ) |
Undo the normalization of for loop's C99 init declaration. Previous record of normalization is used to ease the reverse transformation.
Definition at line 11766 of file sageInterface.C.
References SgForStatement::get_for_init_stmt(), getFirstVarSym(), removeStatement(), and SgNode::set_parent().
bool SageInterface::forLoopNormalization | ( | SgForStatement * | loop, |
bool | foldConstant = true |
||
) |
Normalize a for loop, return true if successful.
Normalize a for loop, part of migrating Qing's loop handling into SageInterface.
Generated constants will be fold by default.
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
Definition at line 11944 of file sageInterface.C.
References constantFolding(), ensureBasicBlockAsBodyOfFor(), normalizeForLoopIncrement(), normalizeForLoopInitDeclaration(), and normalizeForLoopTest().
Referenced by loopCollapsing(), loopTiling(), and loopUnrolling().
bool SageInterface::normalizeForLoopTest | ( | SgForStatement * | loop | ) |
Normalize a for loop's test expression i<x is normalized to i<= (x-1) and i>x is normalized to i>= (x+1)
Definition at line 11819 of file sageInterface.C.
References SageBuilder::buildAddOp(), SageBuilder::buildGreaterOrEqualOp(), SageBuilder::buildIntVal(), SageBuilder::buildLessOrEqualOp(), SageBuilder::buildSubtractOp(), deepCopy(), SgBinaryOp::get_lhs_operand(), SgBinaryOp::get_rhs_operand(), SgForStatement::get_test_expr(), replaceExpression(), and SgExpression::variantT().
Referenced by forLoopNormalization().
bool SageInterface::normalizeForLoopIncrement | ( | SgForStatement * | loop | ) |
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++;}
Definition at line 11871 of file sageInterface.C.
References SageBuilder::buildIntVal(), SageBuilder::buildMultiplyOp(), SageBuilder::buildPlusAssignOp(), copyExpression(), deepCopy(), SgBinaryOp::get_lhs_operand(), SgBinaryOp::get_rhs_operand(), SgForStatement::get_test_expr(), replaceExpression(), and SgExpression::variantT().
Referenced by forLoopNormalization().
bool SageInterface::doLoopNormalization | ( | SgFortranDo * | loop | ) |
Normalize a Fortran Do loop. Make the default increment expression (1) explicit.
Definition at line 11979 of file sageInterface.C.
References SageBuilder::buildIntVal(), and SgNode::set_parent().
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.
Definition at line 12061 of file sageInterface.C.
References appendStatement(), attachComment(), SageBuilder::buildAddOp(), SageBuilder::buildAssignInitializer(), SageBuilder::buildConditionalExp(), SageBuilder::buildDivideOp(), SageBuilder::buildEqualityOp(), SageBuilder::buildIntType(), SageBuilder::buildIntVal(), SageBuilder::buildModOp(), SageBuilder::buildMultiplyOp(), SageBuilder::buildSubtractOp(), SageBuilder::buildVariableDeclaration(), SageBuilder::buildVarRefExp(), copyExpression(), deepCopy(), dumpInfo(), forLoopNormalization(), gensym_counter, SgForStatement::get_for_init_stmt(), SgForStatement::get_loop_body(), SgNode::get_parent(), SgStatement::get_scope(), SgInitializedName::get_symbol_from_symbol_table(), SgVariableDeclaration::get_variables(), insertStatementAfter(), insertStatementBefore(), isCanonicalForLoop(), Rose::StringUtility::numberToString(), removeStatement(), replaceExpression(), SgForStatement::set_for_init_stmt(), SgExpression::set_need_paren(), and SgBinaryOp::set_rhs_operand().
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!).
Interchange/Permutate a n-level perfectly-nested loop rooted at 'loop' using a lexicographical order number within [0,depth!)
Definition at line 12428 of file sageInterface.C.
References SgForStatement::get_for_init_stmt(), SgForStatement::set_for_init_stmt(), SgNode::set_parent(), and setSourcePositionForTransformation().
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.
Tile the n-level (starting from 1) of a perfectly nested loop nest using tiling size s.
Definition at line 12302 of file sageInterface.C.
References appendStatement(), SageBuilder::buildAddOp(), SageBuilder::buildAssignStatement(), SageBuilder::buildBasicBlock(), SageBuilder::buildConditionalExp(), SageBuilder::buildExprStatement(), SageBuilder::buildForStatement(), SageBuilder::buildGreaterOrEqualOp(), SageBuilder::buildIntType(), SageBuilder::buildIntVal(), SageBuilder::buildLessOrEqualOp(), SageBuilder::buildLessThanOp(), SageBuilder::buildMinusAssignOp(), SageBuilder::buildMultiplyOp(), SageBuilder::buildPlusAssignOp(), SageBuilder::buildSubtractOp(), SageBuilder::buildVariableDeclaration(), SageBuilder::buildVarRefExp(), constantFolding(), copyExpression(), dumpInfo(), forLoopNormalization(), SgForStatement::get_loop_body(), SgNode::get_parent(), SgStatement::get_scope(), SgForStatement::get_test_expr(), insertStatementBefore(), isBodyStatement(), isCanonicalForLoop(), makeSingleStatementBodyToBlock(), removeStatement(), SgExpression::set_need_paren(), and SgBinaryOp::set_rhs_operand().
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++;}
Definition at line 23415 of file sageInterface.C.
References SageBuilder::buildAddOp(), SageBuilder::buildAssignInitializer(), SageBuilder::buildAssignStatement(), SageBuilder::buildConditionalExp(), SageBuilder::buildDivideOp(), SageBuilder::buildEqualityOp(), SageBuilder::buildExprListExp(), SageBuilder::buildExprStatement(), SageBuilder::buildForStatement(), SageBuilder::buildIntType(), SageBuilder::buildIntVal(), SageBuilder::buildLessOrEqualOp(), SageBuilder::buildMinusOp(), SageBuilder::buildModOp(), SageBuilder::buildMultiplyOp(), SageBuilder::buildPlusAssignOp(), SageBuilder::buildSubtractOp(), SageBuilder::buildVariableDeclaration(), SageBuilder::buildVarRefExp(), constantFolding(), copyExpression(), deepCopy(), dumpInfo(), findLastDeclarationStatement(), forLoopNormalization(), generateUniqueVariableName(), SgForStatement::get_loop_body(), SgNode::get_parent(), SgStatement::get_scope(), getFirstStatement(), getFirstVarSym(), getGlobalScope(), getNextStatement(), getScope(), insertStatementBefore(), isCanonicalForLoop(), prependStatementList(), replaceStatement(), and SgNode::set_parent().
bool SageInterface::getForLoopInformations | ( | SgForStatement * | for_loop, |
SgVariableSymbol *& | iterator, | ||
SgExpression *& | lower_bound, | ||
SgExpression *& | upper_bound, | ||
SgExpression *& | stride | ||
) |
Definition at line 23721 of file sageInterface.C.
References SageBuilder::buildAddOp(), SageBuilder::buildIntVal(), SageBuilder::buildSubtractOp(), SgForStatement::get_for_init_stmt(), SgForInitStatement::get_init_stmt(), SgBinaryOp::get_lhs_operand_i(), SgBinaryOp::get_rhs_operand_i(), and SgExpression::variantT().
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 1300 of file sageInterface.h.
std::vector< SgFile * > SageInterface::generateFileList | ( | ) |
Returns STL vector of SgFile IR node pointers.
Demonstrates use of restricted traversal over just SgFile IR nodes.
Definition at line 5194 of file sageInterface.C.
References SgSourceFile::traverseMemoryPoolNodes(), and SgBinaryComposite::traverseMemoryPoolNodes().
SgProject * SageInterface::getProject | ( | ) |
Get the current SgProject IR Node.
The library should never have more than one project and it asserts such. If no project has been created yet then this function returns the null pointer.
Definition at line 5241 of file sageInterface.C.
References SgProject::visitRepresentativeNode().
Referenced by getSgNodeFromAbstractHandleString(), and sortSgNodeListBasedOnAppearanceOrderInSource().
Definition at line 5268 of file sageInterface.C.
void SageInterface::serialize | ( | SgNode * | node, |
std::string & | prefix, | ||
bool | hasRemaining, | ||
std::ostringstream & | out, | ||
std::string & | edgeLabel | ||
) |
we have two serialize() functions, one for a single node, the other for a list of pointers
Definition at line 25360 of file sageInterface.C.
References SgNode::class_name(), SgFunctionSymbol::get_name(), SgScopeStatement::get_qualified_name(), SgNode::get_traversalSuccessorContainer(), SgNode::get_traversalSuccessorNamesContainer(), and serialize_list().
void SageInterface::serialize_list | ( | T & | plist, |
std::string | T_name, | ||
std::string & | prefix, | ||
bool | hasRemaining, | ||
std::ostringstream & | out, | ||
std::string & | edgeLabel | ||
) |
Query a subtree to get all nodes of a given type, with an appropriate downcast.
Definition at line 1375 of file sageInterface.h.
Referenced by serialize().
SgFunctionDeclaration * SageInterface::findMain | ( | SgNode * | currentNode | ) |
top-down traversal from current node to find the main() function declaration
Definition at line 7885 of file sageInterface.C.
References findMain(), SgDeclarationStatement::get_definingDeclaration(), SgNode::get_traversalSuccessorContainer(), and isMain().
Referenced by findMain().
SgStatement * SageInterface::findLastDeclarationStatement | ( | SgScopeStatement * | scope, |
bool | includePragma = false |
||
) |
Find the last declaration statement within a scope (if any). This is often useful to decide where to insert another variable declaration statement. Pragma declarations are not treated as a declaration by default in this context.
iterate through the statement within a scope, find the last declaration statement (if any) after which
Definition at line 7908 of file sageInterface.C.
References SgScopeStatement::generateStatementList().
Referenced by insertStatementAfterLastDeclaration(), and loopCollapsing().
vector< SgVariableSymbol * > SageInterface::getSymbolsUsedInExpression | ( | SgExpression * | expr | ) |
Find referenced symbols within an expression.
Definition at line 8622 of file sageInterface.C.
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.
Definition at line 8549 of file sageInterface.C.
Referenced by changeBreakStatementsToGotos().
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.
Definition at line 8591 of file sageInterface.C.
Referenced by changeContinuesToGotos().
vector< SgGotoStatement * > SageInterface::findGotoStmts | ( | SgStatement * | scope, |
SgLabelStatement * | l | ||
) |
Query a subtree to get all nodes of a given type, with an appropriate downcast.
Definition at line 8237 of file sageInterface.C.
References SgGotoStatement::get_label().
vector< SgStatement * > SageInterface::getSwitchCases | ( | SgSwitchStatement * | sw | ) |
Query a subtree to get all nodes of a given type, with an appropriate downcast.
Definition at line 8280 of file sageInterface.C.
References SgSwitchStatement::get_body().
void SageInterface::collectVarRefs | ( | SgLocatedNode * | root, |
std::vector< SgVarRefExp * > & | result | ||
) |
Collect all variable references in a subtree.
Definition at line 13456 of file sageInterface.C.
References collectVariableReferencesInArrayTypes().
Referenced by SageBuilder::buildDefiningFunctionDeclaration_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 1445 of file sageInterface.h.
References SgSymbol::get_name(), and SgNode::get_traversalSuccessorContainer().
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>.
Definition at line 8645 of file sageInterface.C.
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 1570 of file sageInterface.h.
References SgNode::class_name(), SgDeclarationStatement::get_definingDeclaration(), SgNode::get_file_info(), SgDeclarationStatement::get_firstNondefiningDeclaration(), and SgNode::get_parent().
SgSourceFile * SageInterface::getEnclosingSourceFile | ( | SgNode * | n, |
const bool | includingSelf = false |
||
) |
Find enclosing source file node.
Definition at line 8640 of file sageInterface.C.
Referenced by insertHeader(), resetInternalMapsForTargetStatement(), and statementCanBeTransformed().
SgScopeStatement * SageInterface::getScope | ( | const SgNode * | astNode | ) |
Get the closest scope from astNode. Return astNode if it is already a scope.
Definition at line 8308 of file sageInterface.C.
References SgNode::class_name(), SgDeclarationStatement::get_definingDeclaration(), SgNode::get_parent(), and SgStatement::get_scope().
Referenced by fixVariableReferences(), getEnclosingScope(), and loopCollapsing().
SgScopeStatement * SageInterface::getEnclosingScope | ( | SgNode * | n, |
const bool | includingSelf = false |
||
) |
Get the enclosing scope from a node n.
Definition at line 8295 of file sageInterface.C.
References SgNode::get_parent(), and getScope().
Referenced by moveVariableDeclaration().
Traverse back through a node's parents to find the enclosing global scope.
Definition at line 8672 of file sageInterface.C.
Referenced by SageBuilder::buildFunctionRefExp(), SageBuilder::buildFunctionRefExp(), fixFunctionDeclaration(), fixStatement(), insertHeader(), and loopCollapsing().
bool SageInterface::hasSameGlobalScope | ( | SgStatement * | statement_1, |
SgStatement * | statement_2 | ||
) |
This is supporting the recognition of functions in header files from two different ASTs.
Definition at line 962 of file sageInterface.C.
References SgStatement::class_name(), SgGlobal::class_name(), SgNode::get_parent(), and SgFile::getFileName().
Referenced by SageBuilder::findAssociatedDeclarationInTargetAST().
SgFunctionDefinition * SageInterface::getEnclosingProcedure | ( | SgNode * | n, |
const bool | includingSelf = false |
||
) |
Find the function definition.
Definition at line 8651 of file sageInterface.C.
References getEnclosingFunctionDefinition().
Referenced by addStepToLoopBody(), and SageBuilder::buildVariableDeclaration().
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.
Definition at line 8657 of file sageInterface.C.
Referenced by collectReadWriteRefs(), fixLabelStatement(), getEnclosingProcedure(), normalizeForLoopInitDeclaration(), and setFortranNumericLabel().
SgStatement * SageInterface::getEnclosingStatement | ( | SgNode * | n | ) |
Find the closest enclosing statement, including the given node.
Definition at line 9722 of file sageInterface.C.
References SgNode::get_parent().
Referenced by insertAfterUsingCommaOp(), isLoopIndexVariable(), and set_name().
SgSwitchStatement * SageInterface::findEnclosingSwitch | ( | SgStatement * | s | ) |
Find the closest switch outside a given statement (normally used for case and default statements)
Definition at line 11424 of file sageInterface.C.
References SgNode::get_parent().
SgOmpClauseBodyStatement * SageInterface::findEnclosingOmpClauseBodyStatement | ( | SgStatement * | s | ) |
Find enclosing OpenMP clause body statement from s. If s is already one, return it directly.
Definition at line 11433 of file sageInterface.C.
References SgNode::get_parent().
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.
Definition at line 11444 of file sageInterface.C.
References SgNode::get_parent(), and SgStatement::variantT().
Referenced by isLoopIndexVariable().
SgFunctionDeclaration * SageInterface::getEnclosingFunctionDeclaration | ( | SgNode * | astNode, |
const bool | includingSelf = false |
||
) |
Find the enclosing function declaration, including its derived instances like isSgProcedureHeaderStatement, isSgProgramHeaderStatement, and isSgMemberFunctionDeclaration.
Definition at line 8663 of file sageInterface.C.
Referenced by convertRefToInitializedName().
get the SgFile node from current node
Definition at line 9498 of file sageInterface.C.
References SgNode::class_name(), SgClassDeclaration::class_name(), SgNode::get_parent(), SgLocatedNode::getAttribute(), and SgFile::getFileName().
Referenced by SageBuilder::buildNondefiningFunctionDeclaration(), SageBuilder::errorCheckingTargetAST(), SageBuilder::fixupCopyOfAstFromSeparateFileInNewTargetAst(), SageBuilder::fixupCopyOfNodeFromSeparateFileInNewTargetAst(), and saveToPDF().
SgInitializer * SageInterface::getInitializerOfExpression | ( | SgExpression * | n | ) |
Get the initializer containing an expression if it is within an initializer.
Definition at line 8603 of file sageInterface.C.
References SgNode::get_parent(), and SgExpression::sage_class_name().
SgClassDefinition * SageInterface::getEnclosingClassDefinition | ( | SgNode * | astnode, |
const bool | includingSelf = false |
||
) |
Get the closest class definition enclosing the specified AST node,.
Definition at line 8678 of file sageInterface.C.
SgClassDeclaration * SageInterface::getEnclosingClassDeclaration | ( | SgNode * | astNode | ) |
Get the closest class declaration enclosing the specified AST node,.
Definition at line 8684 of file sageInterface.C.
SgExprListExp * SageInterface::getEnclosingExprListExp | ( | SgNode * | astNode, |
const bool | includingSelf = false |
||
) |
Get the enclosing SgExprListExp (used as part of function argument index evaluation in subexpressions).
Definition at line 8691 of file sageInterface.C.
bool SageInterface::isInSubTree | ( | SgExpression * | subtree, |
SgExpression * | exp | ||
) |
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 8696 of file sageInterface.C.
SgFunctionDeclaration * SageInterface::getFunctionDeclaration | ( | SgFunctionCallExp * | functionCallExp | ) |
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 8726 of file sageInterface.C.
References SgBinaryOp::get_rhs_operand(), SgFunctionRefExp::getAssociatedFunctionDeclaration(), and SgMemberFunctionRefExp::getAssociatedMemberFunctionDeclaration().
bool SageInterface::isDataMemberReference | ( | SgVarRefExp * | varRefExp | ) |
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 9363 of file sageInterface.C.
References SgNode::get_parent(), SgStorageModifier::isStatic(), and isStatic().
Referenced by getClassTypeChainForMemberReference().
bool SageInterface::isAddressTaken | ( | SgExpression * | refExp | ) |
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 9471 of file sageInterface.C.
References SgNode::get_parent().
bool SageInterface::isMemberFunctionMemberReference | ( | SgMemberFunctionRefExp * | memberFunctionRefExp | ) |
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 9290 of file sageInterface.C.
References SgNode::get_parent(), SgFunctionDeclaration::get_scope(), SgStorageModifier::isStatic(), and isStatic().
Referenced by getClassTypeChainForMemberReference().
std::list< SgClassType * > SageInterface::getClassTypeChainForMemberReference | ( | SgExpression * | refExp | ) |
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 8786 of file sageInterface.C.
References SgNode::class_name(), SgType::class_name(), SgClassType::class_name(), SgScopeStatement::class_name(), SgClassDefinition::class_name(), SgDeclarationStatement::class_name(), SgClassDeclaration::class_name(), SgExpression::class_name(), SgSymbol::class_name(), SgClassDefinition::get_declaration(), SgDeclarationStatement::get_definingDeclaration(), SgBinaryOp::get_lhs_operand(), SgSymbol::get_name(), SgVariableSymbol::get_name(), get_name(), SgUnaryOp::get_operand(), SgNode::get_parent(), SgStatement::get_scope(), SgTemplateInstantiationMemberFunctionDecl::get_templateDeclaration(), SgExpression::get_type(), SgCastExp::get_type(), isDataMemberReference(), isMemberFunctionMemberReference(), and SgType::stripType().
std::set< SgNode * > SageInterface::getFrontendSpecificNodes | ( | ) |
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 9634 of file sageInterface.C.
References SgNode::get_file_info(), and SgNode::returnDataMemberPointers().
void SageInterface::outputSharedNodes | ( | SgNode * | node | ) |
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 9692 of file sageInterface.C.
References SgNode::class_name(), SgNode::get_file_info(), and Sg_File_Info::isShared().
void SageInterface::displayScope | ( | SgScopeStatement * | scope | ) |
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 26845 of file sageInterface.C.
References SgStatement::class_name(), SgScopeStatement::class_name(), SgScopeStatement::generateStatementList(), and get_name().
return the first global scope under current project
Definition at line 7626 of file sageInterface.C.
SgStatement * SageInterface::getLastStatement | ( | SgScopeStatement * | scope | ) |
get the last statement within a scope, return NULL if it does not exit
Definition at line 7654 of file sageInterface.C.
References SgScopeStatement::containsOnlyDeclarations(), SgScopeStatement::getDeclarationList(), and SgScopeStatement::getStatementList().
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.
Definition at line 7687 of file sageInterface.C.
References SgScopeStatement::containsOnlyDeclarations(), SgLocatedNode::get_file_info(), SgNode::get_file_info(), SgScopeStatement::getDeclarationList(), SgScopeStatement::getStatementList(), Sg_File_Info::isOutputInCodeGeneration(), and Sg_File_Info::isTransformation().
Referenced by loopCollapsing().
SgFunctionDeclaration * SageInterface::findFirstDefiningFunctionDecl | ( | SgScopeStatement * | scope | ) |
Find the first defining function declaration statement in a scope.
Definition at line 7782 of file sageInterface.C.
References SgScopeStatement::containsOnlyDeclarations(), SgDeclarationStatement::get_definingDeclaration(), SgLocatedNode::get_file_info(), SgNode::get_file_info(), SgScopeStatement::getDeclarationList(), SgScopeStatement::getStatementList(), Sg_File_Info::isOutputInCodeGeneration(), and Sg_File_Info::isTransformation().
SgStatement * SageInterface::getNextStatement | ( | SgStatement * | currentStmt | ) |
Get next statement within the same scope of current statement.
Definition at line 11321 of file sageInterface.C.
Referenced by findSurroundingStatementFromSameFile(), loopCollapsing(), mergeDeclarationWithAssignment(), and moveDeclarationToAssociatedNamespace().
SgStatement * SageInterface::getPreviousStatement | ( | SgStatement * | currentStmt, |
bool | climbOutScope = true |
||
) |
Get previous statement of the current statement. It may return a previous statement of a parent scope by default (climbOutScope is true), otherwise only a previous statement of the same scope is returned.
Definition at line 11327 of file sageInterface.C.
References Rose::getPreviousStatement().
Referenced by findSurroundingStatementFromSameFile(), and moveDeclarationToAssociatedNamespace().
void SageInterface::listHeaderFiles | ( | SgIncludeFile * | includeFile | ) |
return path prefix for subtree of include files.
Definition at line 1418 of file sageInterface.C.
References SgNode::class_name().
bool SageInterface::scopeHasStatementsFromSameFile | ( | SgScopeStatement * | scope | ) |
This function supports the token-based unparsing when used with unparsing of header files to know when the scope can be unparsed via it's token stream, even though a statement from a header file may contain a transformation. returns true if there is a statement in the scope that has to be unparsed (is from the same file as the scope). returns false if the scope is empty or contains only statements associated with one or more header files.
Definition at line 1445 of file sageInterface.C.
References SgScopeStatement::containsOnlyDeclarations(), SgLocatedNode::get_file_info(), SgScopeStatement::getDeclarationList(), and SgScopeStatement::getStatementList().
bool SageInterface::isEqualToIntConst | ( | SgExpression * | e, |
int | value | ||
) |
Check if a SgIntVal node has a given value.
Definition at line 11332 of file sageInterface.C.
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
Definition at line 11336 of file sageInterface.C.
References is_C99_language(), is_C_language(), is_Cuda_language(), is_Cxx_language(), is_Fortran_language(), is_Java_language(), is_OpenCL_language(), is_PHP_language(), and is_Python_language().
Referenced by updateDefiningNondefiningLinks().
bool SageInterface::isLastStatement | ( | SgStatement * | stmt | ) |
Check if a statement is the last statement within its closed scope.
Definition at line 11374 of file sageInterface.C.
References SgScopeStatement::containsOnlyDeclarations(), SgScopeStatement::generateStatementList(), SgStatement::get_scope(), SgScopeStatement::getDeclarationList(), and SgScopeStatement::getStatementList().
void SageInterface::deleteAST | ( | SgNode * | node | ) |
Function to delete AST subtree's nodes only, users must take care of any dangling pointers, symbols or types that result.
Definition at line 20311 of file sageInterface.C.
References SgNode::class_name(), SgDeclarationStatement::get_definingDeclaration(), SgDeclarationStatement::get_firstNondefiningDeclaration(), get_name(), SgNode::get_parent(), SgTemplateDeclaration::get_scope(), SgTypedefDeclaration::get_scope(), SgClassDeclaration::get_scope(), SgFunctionDeclaration::get_scope(), SgClassNameRefExp::get_symbol(), SgInitializedName::get_symbol_from_symbol_table(), SgStatement::get_symbol_from_symbol_table(), SgTemplateDeclaration::get_symbol_from_symbol_table(), SgClassDeclaration::get_symbol_from_symbol_table(), SgTemplateInstantiationDecl::get_symbol_from_symbol_table(), SgFunctionDeclaration::get_symbol_from_symbol_table(), SgScopeStatement::get_symbol_table(), and SgSymbolTable::remove().
Referenced by deepDelete().
void SageInterface::deleteAllNodes | ( | ) |
Function to delete AST subtree's nodes only, users must take care of any dangling pointers, symbols or types that result.
Definition at line 160 of file sageInterface.C.
References SgNode::class_name().
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).
Definition at line 21413 of file sageInterface.C.
void SageInterface::moveStatementsBetweenBlocks | ( | SgBasicBlock * | sourceBlock, |
SgBasicBlock * | targetBlock | ||
) |
Move statements in first block to the second block (preserves order and rebuilds the symbol table).
Definition at line 21841 of file sageInterface.C.
void SageInterface::moveStatementsBetweenBlocks | ( | SgAdaPackageSpec * | sourceBlock, |
SgNamespaceDefinitionStatement * | targetBlock | ||
) |
Move statements in Ada's package spec into C++ namespace's definition.
Definition at line 21821 of file sageInterface.C.
References SgNode::get_parent().
void SageInterface::moveStatementsBetweenBlocks | ( | SgAdaPackageBody * | sourceBlock, |
SgNamespaceDefinitionStatement * | targetBlock | ||
) |
Move statements in Ada's package body into C++ namespace's definition.
Definition at line 21828 of file sageInterface.C.
References SgNode::get_parent().
void SageInterface::moveStatementsBetweenBlocks | ( | SgNamespaceDefinitionStatement * | sourceBlock, |
SgNamespaceDefinitionStatement * | targetBlock | ||
) |
Move statements between C++ namespace's definitions.
Definition at line 21835 of file sageInterface.C.
bool SageInterface::isLambdaFunction | ( | SgFunctionDeclaration * | func | ) |
Check if a function declaration is a C++11 lambda function.
Definition at line 21848 of file sageInterface.C.
References SgNode::get_parent().
Referenced by convertRefToInitializedName().
bool SageInterface::isLambdaCapturedVariable | ( | SgVarRefExp * | varRef | ) |
check if a variable reference is this->a[i] inside of a lambda function
Definition at line 21864 of file sageInterface.C.
References SgNode::get_parent().
Referenced by convertRefToInitializedName().
void SageInterface::moveVariableDeclaration | ( | SgVariableDeclaration * | decl, |
SgScopeStatement * | target_scope | ||
) |
Move a variable declaration to a new scope, handle symbol, special scopes like For loop, etc.
Move a variable declaration from its original scope to a new scope, assuming original scope != target_scope.
Definition at line 24247 of file sageInterface.C.
References SageBuilder::buildAssignInitializer(), SgScopeStatement::class_name(), copyExpression(), deepDelete(), SgVariableSymbol::get_name(), SgBinaryOp::get_rhs_operand(), SgStatement::get_scope(), getEnclosingScope(), getFirstInitializedName(), getFirstVarSym(), SgScopeStatement::insert_symbol(), prependStatement(), removeStatement(), SgNode::set_parent(), and SgScopeStatement::variantT().
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.
SageInterface::appendStatement()
Definition at line 13921 of file sageInterface.C.
References SgStatement::class_name(), SgScopeStatement::class_name(), SgClassDeclaration::class_name(), SgScopeStatement::containsOnlyDeclarations(), SageBuilder::e_sourcePositionFrontendConstruction, fixStatement(), SgDeclarationStatement::get_definingDeclaration(), SgDeclarationStatement::get_firstNondefiningDeclaration(), SgNode::get_parent(), SageBuilder::getSourcePositionClassificationMode(), removeStatement(), SgNode::set_parent(), SgScopeStatement::statementExistsInScope(), SageBuilder::topScopeStack(), and updateDefiningNondefiningLinks().
Referenced by addStepToLoopBody(), appendStatementList(), SageBuilder::buildBasicBlock(), convertForToWhile(), insertStatementBeforeFirstNonDeclaration(), instrumentEndOfFunction(), loopTiling(), loopUnrolling(), and replaceExpressionWithStatement().
void SageInterface::appendStatement | ( | SgStatement * | stmt, |
SgForInitStatement * | for_init_stmt | ||
) |
Append a statement to the end of SgForInitStatement.
Definition at line 14122 of file sageInterface.C.
References SgStatement::class_name(), SgScopeStatement::class_name(), and resetInternalMapsForTargetStatement().
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.
Definition at line 14149 of file sageInterface.C.
References appendStatement().
Referenced by SageBuilder::buildBasicBlock_nfi(), and insertStatementListBeforeFirstNonDeclaration().
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).
Definition at line 19985 of file sageInterface.C.
References addMessageStatement(), SgLocatedNode::addToAttachedPreprocessingInfo(), SgNode::class_name(), SgGlobal::class_name(), SgDeclarationStatement::class_name(), Rose::AST::Utility::edgePointerReplacement(), SgDeclarationStatement::get_definingDeclaration(), SgLocatedNode::get_file_info(), SgDeclarationStatement::get_firstNondefiningDeclaration(), get_name(), SgNode::get_parent(), SgStatement::get_scope(), SgDeclarationStatement::get_symbol_from_symbol_table(), SgProject::get_verbose(), SgScopeStatement::getDeclarationList(), getDependentDeclarations(), SgFile::getFileName(), SgStatement::insert_statement(), SgNode::set_parent(), and SgDeclarationStatement::variantT().
void SageInterface::prependStatement | ( | SgStatement * | stmt, |
SgScopeStatement * | scope = NULL |
||
) |
Prepend a statement to the beginning of the current scope, handling side effects as appropriate.
SageInterface::prependStatement()
Definition at line 14179 of file sageInterface.C.
References SgStatement::class_name(), SgScopeStatement::class_name(), SageBuilder::e_sourcePositionFrontendConstruction, fixStatement(), SageBuilder::getSourcePositionClassificationMode(), resetInternalMapsForTargetStatement(), SgNode::set_parent(), SageBuilder::topScopeStack(), and updateDefiningNondefiningLinks().
Referenced by SageBuilder::buildOpaqueType(), insertStatementAfterLastDeclaration(), moveVariableDeclaration(), normalizeForLoopInitDeclaration(), and prependStatementList().
void SageInterface::prependStatement | ( | SgStatement * | stmt, |
SgForInitStatement * | for_init_stmt | ||
) |
Prepend a statement to the beginning of SgForInitStatement.
Definition at line 14260 of file sageInterface.C.
References SgStatement::class_name(), SgScopeStatement::class_name(), and resetInternalMapsForTargetStatement().
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
Definition at line 14286 of file sageInterface.C.
References prependStatement().
Referenced by loopCollapsing().
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 .
Check if a scope statement has a simple children statement list (SgStatementPtrList) so insert additional statements under the scope is straightforward and unambiguous .
for example, SgBasicBlock has a simple statement list while IfStmt does not.
Definition at line 14297 of file sageInterface.C.
References SgScopeStatement::variantT().
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.
Definition at line 14370 of file sageInterface.C.
References SgLocatedNode::addToAttachedPreprocessingInfo(), SageBuilder::buildBasicBlock(), SgStatement::class_name(), SgScopeStatement::class_name(), SageBuilder::e_sourcePositionFrontendConstruction, fixStatement(), SgNode::get_parent(), SgStatement::get_scope(), SgLocatedNode::getAttachedPreprocessingInfo(), SageBuilder::getSourcePositionClassificationMode(), SgStatement::insert_statement(), insertStatement(), SgWhileStmt::set_body(), SgDoWhileStmt::set_body(), SgIfStmt::set_false_body(), SgForStatement::set_loop_body(), SgNode::set_parent(), SgIfStmt::set_true_body(), and updateDefiningNondefiningLinks().
Referenced by changeBreakStatementsToGotos(), insertStatement(), insertStatementAfter(), and insertStatementBefore().
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.
Definition at line 14712 of file sageInterface.C.
References insertStatementAfter(), and insertStatementBefore().
Referenced by insertStatementListAfter(), and insertStatementListBefore().
void SageInterface::insertStatementBefore | ( | SgStatement * | targetStmt, |
SgStatement * | newStmt, | ||
bool | autoMovePreprocessingInfo = true |
||
) |
Insert a statement before a target statement.
Definition at line 14799 of file sageInterface.C.
References insertStatement().
Referenced by insertAfterUsingCommaOp(), insertStatementBeforeFirstNonDeclaration(), insertStatementList(), instrumentEndOfFunction(), loopCollapsing(), loopTiling(), loopUnrolling(), and mergeDeclarationWithAssignment().
void SageInterface::insertStatementListBefore | ( | SgStatement * | targetStmt, |
const std::vector< SgStatement * > & | newStmts | ||
) |
Insert a list of statements before a target statement.
Definition at line 14804 of file sageInterface.C.
References insertStatementList().
Referenced by insertStatementListBeforeFirstNonDeclaration().
void SageInterface::insertStatementAfter | ( | SgStatement * | targetStmt, |
SgStatement * | newStmt, | ||
bool | autoMovePreprocessingInfo = true |
||
) |
Insert a statement after a target statement, Move around preprocessing info automatically by default.
Definition at line 14730 of file sageInterface.C.
References insertStatement().
Referenced by insertStatementAfterLastDeclaration(), insertStatementAfterLastDeclaration(), insertStatementList(), loopUnrolling(), and splitVariableDeclaration().
void SageInterface::insertStatementListAfter | ( | SgStatement * | targetStmt, |
const std::vector< SgStatement * > & | newStmt | ||
) |
Insert a list of statements after a target statement.
Definition at line 14735 of file sageInterface.C.
References insertStatementList().
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.
Definition at line 14741 of file sageInterface.C.
References findLastDeclarationStatement(), insertStatementAfter(), and prependStatement().
Referenced by insertStatementAfterLastDeclaration().
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.
Definition at line 14754 of file sageInterface.C.
References insertStatementAfter(), and insertStatementAfterLastDeclaration().
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.
Definition at line 14774 of file sageInterface.C.
References appendStatement(), SgScopeStatement::generateStatementList(), insertStatementBefore(), and movePreprocessingInfo().
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.
Definition at line 14787 of file sageInterface.C.
References appendStatementList(), SgScopeStatement::generateStatementList(), and insertStatementListBefore().
SgStatement * SageInterface::lastFrontEndSpecificStatement | ( | SgGlobal * | globalScope | ) |
Function to delete AST subtree's nodes only, users must take care of any dangling pointers, symbols or types that result.
Definition at line 14334 of file sageInterface.C.
References SgStatement::class_name(), and SgGlobal::get_declarations().
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()).
Remove a statement: TODO consider side effects for symbol tables.
Definition at line 9998 of file sageInterface.C.
References SgStatement::class_name(), findSurroundingStatementFromSameFile(), get_name(), SgNode::get_parent(), SgLocatedNode::getAttachedPreprocessingInfo(), moveCommentsToNewStatement(), moveUpInnerDanglingIfEndifDirective(), SgStatement::remove_statement(), and resetInternalMapsForTargetStatement().
Referenced by appendStatement(), loopTiling(), loopUnrolling(), mergeAssignmentWithDeclaration(), mergeDeclarationWithAssignment(), moveVariableDeclaration(), normalizeForLoopInitDeclaration(), setBaseTypeDefiningDeclaration(), and unnormalizeForLoopInitDeclaration().
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()
Deep delete a sub AST tree. It uses postorder traversal to delete each child node.
Definition at line 10567 of file sageInterface.C.
References deleteAST(), and AstSimpleProcessing::traverse().
Referenced by moveVariableDeclaration(), and replaceExpression().
void SageInterface::replaceStatement | ( | SgStatement * | oldStmt, |
SgStatement * | newStmt, | ||
bool | movePreprocessinInfo = false |
||
) |
Replace a statement with another. Move preprocessing information from oldStmt to newStmt if requested.
Replace a statement with another.
Definition at line 10583 of file sageInterface.C.
References SageBuilder::buildBasicBlock(), SgLocatedNode::get_endOfConstruct(), SgNode::get_parent(), SgLocatedNode::get_startOfConstruct(), movePreprocessingInfo(), moveUpInnerDanglingIfEndifDirective(), moveUpPreprocessingInfo(), SgStatement::replace_statement(), and SgNode::set_parent().
Referenced by loopCollapsing(), removeUnusedLabels(), and replaceDefiningFunctionDeclarationWithFunctionPrototype().
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.
Replace an anchor node with a specified pattern subtree with optional SgVariantExpression.
Definition at line 10906 of file sageInterface.C.
References deepCopy(), replaceExpression(), and SgExpression::variantT().
void SageInterface::replaceVariableReferences | ( | SgVariableSymbol * | old_sym, |
SgVariableSymbol * | new_sym, | ||
SgScopeStatement * | scope | ||
) |
Replace all variable references to an old symbol in a scope to being references to a new symbol.
Definition at line 24158 of file sageInterface.C.
bool SageInterface::statementCanBeTransformed | ( | SgStatement * | stmt | ) |
If header file unparsing and token-based unparsing are used, then some statements in header files used with the same name and different include syntax can't be transformed.
This is currently because there is no way to generally test the resulting transformed code generated by ROSE.
This is currently because there is no way to generally test the resulting transformed code generated by ROSE. NOTE: This is demonstrated by test8 in the unparse headers tests directory.
Definition at line 24181 of file sageInterface.C.
References getEnclosingSourceFile().
Referenced by set_name().
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.
expression | Expression which will be replaced by a variable |
scope | scope in which the temporary variable will be generated |
reEvaluate | an assignment op to reevaluate the expression. Leave NULL if not needed |
Definition at line 10968 of file sageInterface.C.
References SageBuilder::buildAddressOfOp(), SageBuilder::buildAssignInitializer(), SageBuilder::buildAssignOp(), SageBuilder::buildPointerDerefExp(), SageBuilder::buildPointerType(), SageBuilder::buildReferenceType(), SageBuilder::buildVariableDeclaration(), SageBuilder::buildVarRefExp(), copyExpression(), generateUniqueVariableName(), SgExpression::get_type(), isReferenceType(), SgExpression::set_lvalue(), and SgType::stripType().
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.
Definition at line 11044 of file sageInterface.C.
References SageBuilder::buildAssignInitializer(), SageBuilder::buildPointerType(), SageBuilder::buildVariableDeclaration(), SageBuilder::buildVarRefExp(), copyExpression(), generateUniqueVariableName(), and SgExpression::get_type().
SgVariableSymbol * SageInterface::appendArg | ( | SgFunctionParameterList * | paraList, |
SgInitializedName * | initName | ||
) |
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.
Definition at line 13898 of file sageInterface.C.
Referenced by SageBuilder::buildFunctionParameterList(), SageBuilder::buildFunctionParameterList(), and SageBuilder::buildFunctionParameterList_nfi().
SgVariableSymbol * SageInterface::prependArg | ( | SgFunctionParameterList * | paraList, |
SgInitializedName * | initName | ||
) |
Prepend an argument to SgFunctionParameterList.
Definition at line 13903 of file sageInterface.C.
void SageInterface::appendExpression | ( | SgExprListExp * | expList, |
SgExpression * | exp | ||
) |
Append an expression to a SgExprListExp, set the parent pointer also.
Definition at line 13775 of file sageInterface.C.
References SgNode::set_parent().
Referenced by appendExpressionList(), SageBuilder::buildExprListExp(), SageBuilder::buildExprListExp(), SageBuilder::buildExprListExp_nfi(), SageBuilder::buildListExp(), and SageBuilder::buildTupleExp().
void SageInterface::appendExpressionList | ( | SgExprListExp * | expList, |
const std::vector< SgExpression * > & | exp | ||
) |
Append an expression list to a SgExprListExp, set the parent pointers also.
Definition at line 13783 of file sageInterface.C.
References appendExpression().
Referenced by SageBuilder::buildListExp(), SageBuilder::buildListExp_nfi(), SageBuilder::buildTupleExp(), and SageBuilder::buildTupleExp_nfi().
void SageInterface::setParameterList | ( | actualFunction * | func, |
SgFunctionParameterList * | paralist | ||
) |
Set parameter list for a function declaration, considering existing parameter list etc.
Definition at line 2196 of file sageInterface.h.
References SgFunctionParameterList::get_args(), SgNode::get_parent(), is_Ada_language(), and SgNode::set_parent().
Referenced by SageBuilder::buildDefiningFunctionDeclaration_T().
void SageInterface::setPragma | ( | SgPragmaDeclaration * | decl, |
SgPragma * | pragma | ||
) |
Set a pragma of a pragma declaration. handle memory release for preexisting pragma, and set parent pointer.
Definition at line 13908 of file sageInterface.C.
References SgNode::set_parent().
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.
Definition at line 11101 of file sageInterface.C.
References SgNode::class_name(), deepDelete(), SgConditionalExp::get_conditional_exp(), SgConditionalExp::get_false_exp(), SgCaseOptionStmt::get_key(), SgExpression::get_lvalue(), SgNode::get_parent(), SgConditionalExp::get_true_exp(), SgExprListExp::replace_expression(), SgExpression::replace_expression(), SgConditionalExp::set_conditional_exp(), SgConditionalExp::set_false_exp(), SgCaseOptionStmt::set_key(), SgBinaryOp::set_lhs_operand(), SgExpression::set_lvalue(), SgExpression::set_need_paren(), SgUnaryOp::set_operand_i(), SgNode::set_parent(), SgBinaryOp::set_rhs_operand(), and SgConditionalExp::set_true_exp().
Referenced by insertAfterUsingCommaOp(), insertBeforeUsingCommaOp(), loopUnrolling(), normalizeArrowExpWithAddressOfLeftOperand(), normalizeForLoopIncrement(), normalizeForLoopTest(), and replaceWithPattern().
void SageInterface::replaceExpressionWithStatement | ( | SgExpression * | from, |
SageInterface::StatementGenerator * | to | ||
) |
Replace a given expression with a list of statements produced by a generator.
Definition at line 17957 of file sageInterface.C.
References addStepToLoopBody(), appendStatement(), SageBuilder::buildAssignInitializer(), SageBuilder::buildAssignStatement(), SageBuilder::buildBasicBlock(), SageBuilder::buildBoolType(), SageBuilder::buildBoolValExp(), SageBuilder::buildCastExp(), SageBuilder::buildExprStatement(), SageBuilder::buildNullExpression(), SageBuilder::buildVariableDeclaration(), SageBuilder::buildVarRefExp(), SgWhileStmt::get_condition(), SgDoWhileStmt::get_condition(), SgIfStmt::get_conditional(), SgSwitchStatement::get_item_selector(), SgNode::get_parent(), SgScopeStatement::get_symbol_table(), SgExpression::get_type(), SgVariableDeclaration::get_variables(), getBoolType(), getFirstVarSym(), SgScopeStatement::insert_symbol(), myRemoveStatement(), replaceSubexpressionWithStatement(), SgDoWhileStmt::set_condition(), SgIfStmt::set_conditional(), SgSwitchStatement::set_item_selector(), SgExpression::set_lvalue(), and SgNode::set_parent().
Referenced by splitExpression(), and splitExpressionIntoBasicBlock().
void SageInterface::replaceSubexpressionWithStatement | ( | SgExpression * | from, |
SageInterface::StatementGenerator * | to | ||
) |
Similar to replaceExpressionWithStatement, but with more restrictions.
Replace a given expression with a list of statements produced by a generator.
Assumptions: from is not within the test of a loop or ifStmt, not currently traversing from or the statement it is in
The generator, when given a variable as input, must produce some code which leaves its result in the given variable. The output from the generator is then inserted into the original program in such a way that whenever the expression had previously been evaluated, the statements produced by the generator are run instead and their result is used in place of the expression. Assumptions: not currently traversing from or the statement it is in
Definition at line 18202 of file sageInterface.C.
References SgBinaryOp::get_lhs_operand(), SgNode::get_parent(), SgStatement::replace_statement(), SgNode::set_parent(), and splitExpression().
Referenced by replaceExpressionWithStatement().
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.
Definition at line 14812 of file sageInterface.C.
References SgAssignInitializer::set_operand(), SgUnaryOp::set_operand_i(), and SgNode::set_parent().
void SageInterface::setLhsOperand | ( | SgExpression * | target, |
SgExpression * | lhs | ||
) |
set left hand operand for binary expressions, transparently downcasting target expressions when necessary
Definition at line 14855 of file sageInterface.C.
References SgBinaryOp::get_rhs_operand(), SgBinaryOp::set_lhs_operand(), and SgNode::set_parent().
void SageInterface::setRhsOperand | ( | SgExpression * | target, |
SgExpression * | rhs | ||
) |
set left hand operand for binary expression
Definition at line 14894 of file sageInterface.C.
References SgBinaryOp::get_lhs_operand(), SgNode::set_parent(), and SgBinaryOp::set_rhs_operand().
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.
Definition at line 11405 of file sageInterface.C.
void SageInterface::moveToSubdirectory | ( | std::string | directoryName, |
SgFile * | file | ||
) |
Move file to be generated in a subdirectory (will be generated by the unparser).
Definition at line 14933 of file sageInterface.C.
References SgNode::get_parent(), and SgNode::set_parent().
SgStatement * SageInterface::findSurroundingStatementFromSameFile | ( | SgStatement * | targetStmt, |
bool & | surroundingStatementPreceedsTargetStatement | ||
) |
Supporting function to comment relocation in insertStatement() and removeStatement().
Remove a statement: TODO consider side effects for symbol tables.
Definition at line 10365 of file sageInterface.C.
References Sg_File_Info::BAD_FILE_ID, SgStatement::class_name(), SgLocatedNode::get_file_info(), Sg_File_Info::get_line(), get_name(), getNextStatement(), and getPreviousStatement().
Referenced by removeStatement().
void SageInterface::moveCommentsToNewStatement | ( | SgStatement * | sourceStatement, |
const std::vector< int > & | indexList, | ||
SgStatement * | destinationStatement, | ||
bool | destinationStatementPreceedsSourceStatement | ||
) |
Relocate comments and CPP directives from one statement to another.
Definition at line 10194 of file sageInterface.C.
References SgLocatedNode::addToAttachedPreprocessingInfo(), SgStatement::class_name(), SgLocatedNode::get_file_info(), Sg_File_Info::get_line(), get_name(), SgLocatedNode::getAttachedPreprocessingInfo(), SgLocatedNode::insertToAttachedPreprocessingInfo(), is_C99_language(), is_C_language(), is_Cxx_language(), isAncestor(), and printOutComments().
Referenced by removeStatement().
void SageInterface::moveDeclarationToAssociatedNamespace | ( | SgDeclarationStatement * | declarationStatement | ) |
Relocate the declaration to be explicitly represented in its associated namespace (required for some backend compilers to process template instantiations).
Definition at line 10658 of file sageInterface.C.
References SgNode::class_name(), SgStatement::class_name(), SgScopeStatement::class_name(), SgDeclarationStatement::class_name(), SgNamespaceDeclarationStatement::get_name(), SgNode::get_parent(), SgStatement::get_scope(), getNextStatement(), and getPreviousStatement().
Referenced by wrapAllTemplateInstantiationsInAssociatedNamespaces().
bool SageInterface::isTemplateInstantiationNode | ( | SgNode * | node | ) |
Function to delete AST subtree's nodes only, users must take care of any dangling pointers, symbols or types that result.
Definition at line 10811 of file sageInterface.C.
Referenced by wrapAllTemplateInstantiationsInAssociatedNamespaces().
void SageInterface::wrapAllTemplateInstantiationsInAssociatedNamespaces | ( | SgProject * | root | ) |
Function to delete AST subtree's nodes only, users must take care of any dangling pointers, symbols or types that result.
Definition at line 10860 of file sageInterface.C.
References RoseAst::begin(), RoseAst::end(), isTemplateInstantiationNode(), and moveDeclarationToAssociatedNamespace().
void SageInterface::resetInternalMapsForTargetStatement | ( | SgStatement * | sourceStatement | ) |
Reset internal data structures used for token-based unparsing and macro summaries based on modifications to this statement.
Definition at line 10113 of file sageInterface.C.
References SgStatement::class_name(), SgLocatedNode::get_file_info(), getEnclosingSourceFile(), SgLocatedNode::setOutputInCodeGeneration(), and SgLocatedNode::setTransformation().
Referenced by appendStatement(), prependStatement(), prependStatement(), and removeStatement().
void SageInterface::convertFunctionDefinitionsToFunctionPrototypes | ( | SgNode * | node | ) |
XXX This function operates on the new file used to support outlined function definitions. We use a copy of the file where the code will be outlined FROM, so that if there are references to declarations in the outlined code we can support the outpiled code with those references. This approach has the added advantage of also supporting the same include file tree as the original file where the outlined code is being taken from.
Definition at line 27388 of file sageInterface.C.
References generateFunctionDefinitionsList(), and replaceDefiningFunctionDeclarationWithFunctionPrototype().
SgFunctionDeclaration * SageInterface::replaceDefiningFunctionDeclarationWithFunctionPrototype | ( | SgFunctionDeclaration * | functionDeclaration | ) |
Function to delete AST subtree's nodes only, users must take care of any dangling pointers, symbols or types that result.
Definition at line 27257 of file sageInterface.C.
References buildFunctionPrototype(), SgLocatedNode::get_file_info(), SgNode::get_parent(), SgLocatedNode::getAttachedPreprocessingInfo(), SgStorageModifier::isStatic(), movePreprocessingInfo(), printOutComments(), and replaceStatement().
Referenced by convertFunctionDefinitionsToFunctionPrototypes().
std::vector< SgFunctionDeclaration * > SageInterface::generateFunctionDefinitionsList | ( | SgNode * | node | ) |
Function to delete AST subtree's nodes only, users must take care of any dangling pointers, symbols or types that result.
Definition at line 27340 of file sageInterface.C.
References SgDeclarationStatement::get_definingDeclaration(), and SgNode::get_parent().
Referenced by convertFunctionDefinitionsToFunctionPrototypes().
SgFunctionDeclaration * SageInterface::buildFunctionPrototype | ( | SgFunctionDeclaration * | functionDeclaration | ) |
Function to delete AST subtree's nodes only, users must take care of any dangling pointers, symbols or types that result.
Definition at line 26868 of file sageInterface.C.
References SageBuilder::buildEmptyDeclaration(), SageBuilder::buildFunctionParameterList(), SageBuilder::buildNondefiningFunctionDeclaration(), SageBuilder::buildNondefiningMemberFunctionDeclaration(), SageBuilder::buildNondefiningTemplateFunctionDeclaration(), SageBuilder::buildNondefiningTemplateMemberFunctionDeclaration(), SgFunctionDeclaration::class_name(), SgDeclarationStatement::get_definingDeclaration(), SgLocatedNode::get_file_info(), SgDeclarationStatement::get_firstNondefiningDeclaration(), SgNode::get_parent(), SgFunctionDeclaration::get_scope(), SgDeclarationStatement::get_template_name(), SgTemplateInstantiationMemberFunctionDecl::get_templateArguments(), SgTemplateInstantiationFunctionDecl::get_templateArguments(), SgTemplateInstantiationMemberFunctionDecl::get_templateDeclaration(), SgTemplateInstantiationFunctionDecl::get_templateDeclaration(), SgTemplateInstantiationMemberFunctionDecl::get_templateName(), SgTemplateInstantiationFunctionDecl::get_templateName(), SgLocatedNode::getAttachedPreprocessingInfo(), SgDeclarationStatement::set_definingDeclaration(), SgDeclarationStatement::set_firstNondefiningDeclaration(), and SgFunctionDeclaration::variantT().
Referenced by replaceDefiningFunctionDeclarationWithFunctionPrototype().
int SageInterface::fixVariableReferences | ( | SgNode * | root, |
bool | cleanUnusedSymbol = true |
||
) |
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.
Definition at line 15286 of file sageInterface.C.
References clearUnusedVariableSymbols(), SgTypeUnknown::createType(), fixVariableReferences(), SgDeclarationStatement::get_definingDeclaration(), SgNode::get_parent(), getScope(), lookupVariableSymbolInParentScopes(), and SgType::stripType().
Referenced by SageBuilder::buildForStatement(), fixVariableDeclaration(), and fixVariableReferences().
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().
Definition at line 15174 of file sageInterface.C.
References SgScopeStatement::class_name(), SgVariableSymbol::class_name(), fixVariableReferences(), SgNode::get_parent(), SgVariableDeclaration::get_variables(), SgScopeStatement::insert_symbol(), is_Fortran_language(), SgNode::set_parent(), and SageBuilder::topScopeStack().
Referenced by SageBuilder::buildForStatement(), SageBuilder::buildTemplateVariableDeclaration_nfi(), SageBuilder::buildVariableDeclaration(), SageBuilder::buildVariableDeclaration_nfi(), and fixStatement().
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.
Definition at line 14986 of file sageInterface.C.
References SgClassType::class_name(), SgScopeStatement::class_name(), SgDeclarationStatement::class_name(), SgClassType::createType(), SgDeclarationStatement::get_definingDeclaration(), SgDeclarationStatement::get_firstNondefiningDeclaration(), SgNode::get_parent(), SgClassDeclaration::get_scope(), SgClassDeclaration::get_symbol_from_symbol_table(), SgScopeStatement::insert_symbol(), SgNode::set_parent(), SgClassDeclaration::set_scope(), and SgClassType::variantT().
Referenced by SageBuilder::buildClassDeclaration_nfi(), SageBuilder::buildStructDeclaration(), fixClassDeclaration(), and fixStatement().
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.
Definition at line 15121 of file sageInterface.C.
References fixStructDeclaration().
Referenced by fixStatement().
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.
Definition at line 15127 of file sageInterface.C.
References SgScopeStatement::class_name(), SgDeclarationStatement::get_definingDeclaration(), SgDeclarationStatement::get_firstNondefiningDeclaration(), SgNamespaceDeclarationStatement::get_name(), SgNode::get_parent(), SgStatement::get_scope(), SgNamespaceDeclarationStatement::get_symbol_from_symbol_table(), SgScopeStatement::insert_symbol(), SgNode::set_parent(), and SgStatement::set_scope().
Referenced by SageBuilder::buildNamespaceDeclaration_nfi().
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.
fixup symbol table for SgLableStatement. Used Internally when the label is built without knowing its target scope. Both parameters cannot be NULL.
Definition at line 15496 of file sageInterface.C.
References SgLabelStatement::get_label(), SgLabelSymbol::get_name(), getEnclosingFunctionDefinition(), SgScopeStatement::insert_symbol(), is_Ada_language(), and SgLabelStatement::set_scope().
Referenced by SageBuilder::buildLabelStatement(), SageBuilder::buildLabelStatement_nfi(), and fixStatement().
void SageInterface::setFortranNumericLabel | ( | SgStatement * | stmt, |
int | label_value, | ||
SgLabelSymbol::label_type_enum | label_type = SgLabelSymbol::e_start_label_type , |
||
SgScopeStatement * | label_scope = NULL |
||
) |
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.
Set a numerical label for a Fortran statement. The statement should have a enclosing function definition already. SgLabelSymbol and SgLabelR.
Definition at line 15532 of file sageInterface.C.
References SageBuilder::buildLabelRefExp(), getEnclosingFunctionDefinition(), SgScopeStatement::insert_symbol(), Rose::StringUtility::numberToString(), and SgNode::set_parent().
int SageInterface::suggestNextNumericLabel | ( | SgFunctionDefinition * | func_def | ) |
Suggest next usable (non-conflicting) numeric label value for a Fortran function definition scope.
Definition at line 15590 of file sageInterface.C.
References SgScopeStatement::get_symbol_table(), SgSymbolTable::get_symbols(), and is_Fortran_language().
void SageInterface::fixFunctionDeclaration | ( | SgFunctionDeclaration * | stmt, |
SgScopeStatement * | scope | ||
) |
Fix the symbol table and set scope (only if scope in declaration is not already set).
fixup symbol table for SgFunctionDeclaration (and template instantiations, member functions, and member function template instantiations). Used Internally when the function is built without knowing its target scope. Both parameters cannot be NULL.
Definition at line 15618 of file sageInterface.C.
References SgFunctionType::class_name(), SgScopeStatement::class_name(), SgFunctionDeclaration::class_name(), SgNode::get_globalFunctionTypeTable(), SgNode::get_parent(), SgFunctionDeclaration::get_scope(), SgTemplateInstantiationMemberFunctionDecl::get_templateArguments(), SgTemplateInstantiationFunctionDecl::get_templateArguments(), getGlobalScope(), SgScopeStatement::insert_symbol(), SgNode::set_parent(), SgFunctionDeclaration::variantT(), SgTemplateFunctionDeclaration::variantT(), SgMemberFunctionDeclaration::variantT(), SgTemplateMemberFunctionDeclaration::variantT(), SgProgramHeaderStatement::variantT(), and SgProcedureHeaderStatement::variantT().
Referenced by fixStatement().
void SageInterface::fixTemplateDeclaration | ( | SgTemplateDeclaration * | stmt, |
SgScopeStatement * | scope | ||
) |
Fix the symbol table and set scope (only if scope in declaration is not already set).
fixup symbol table for SgFunctionDeclaration (and template instantiations, member functions, and member function template instantiations). Used Internally when the function is built without knowing its target scope. Both parameters cannot be NULL.
Definition at line 15758 of file sageInterface.C.
Referenced by fixStatement().
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.
A wrapper containing fixes (fixVariableDeclaration(),fixStructDeclaration(), fixLabelStatement(), etc) for all kinds statements.
Definition at line 15766 of file sageInterface.C.
References SgFunctionType::class_name(), SgStatement::class_name(), SgScopeStatement::class_name(), fixClassDeclaration(), fixFunctionDeclaration(), fixLabelStatement(), fixStructDeclaration(), fixTemplateDeclaration(), fixVariableDeclaration(), SgDeclarationStatement::get_definingDeclaration(), SgDeclarationStatement::get_firstNondefiningDeclaration(), SgNode::get_globalFunctionTypeTable(), SgNode::get_parent(), SgStatement::get_scope(), SgFunctionDeclaration::get_symbol_from_symbol_table(), getGlobalScope(), SgStatement::hasExplicitScope(), SgScopeStatement::insert_symbol(), isStructDeclaration(), SgDeclarationStatement::set_firstNondefiningDeclaration(), SgNode::set_parent(), SgStatement::set_scope(), and SgStatement::variantT().
Referenced by appendStatement(), insertStatement(), and prependStatement().
std::set< SgStatement * > SageInterface::collectTransformedStatements | ( | SgNode * | node | ) |
This collects the statements that are marked as transformed (useful in debugging).
Definition at line 24698 of file sageInterface.C.
References SgLocatedNode::isTransformation().
std::set< SgStatement * > SageInterface::collectModifiedStatements | ( | SgNode * | node | ) |
This collects the statements that are marked as modified (a flag automatically set by all set_* generated functions) (useful in debugging).
Definition at line 24729 of file sageInterface.C.
References SgNode::class_name(), and SgNode::get_isModified().
Referenced by reportModifiedStatements().
std::set< SgLocatedNode * > SageInterface::collectModifiedLocatedNodes | ( | SgNode * | node | ) |
This collects the SgLocatedNodes that are marked as modified (a flag automatically set by all set_* generated functions) (useful in debugging).
Definition at line 24811 of file sageInterface.C.
References SgNode::class_name(), SgLocatedNode::class_name(), and SgNode::get_isModified().
Referenced by SageBuilder::buildFile(), SageBuilder::buildSourceFile(), and reportModifiedLocatedNodes().
void SageInterface::resetModifiedLocatedNodes | ( | const std::set< SgLocatedNode * > & | modifiedNodeSet | ) |
Use the set of IR nodes and set the isModified flag in each IR node to true.
Definition at line 24851 of file sageInterface.C.
References SgLocatedNode::class_name(), and SgNode::set_isModified().
Referenced by SageBuilder::buildFile().
void SageInterface::reportModifiedStatements | ( | const std::string & | label, |
SgNode * | node | ||
) |
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.
Definition at line 24874 of file sageInterface.C.
References collectModifiedStatements(), SgNode::get_parent(), and SgFile::getFileName().
Referenced by SageBuilder::buildFile().
void SageInterface::reportModifiedLocatedNodes | ( | const std::string & | label, |
SgNode * | node | ||
) |
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.
Definition at line 24946 of file sageInterface.C.
References collectModifiedLocatedNodes(), SgNode::get_parent(), and SgFile::getFileName().
Referenced by SageBuilder::buildFile().
void SageInterface::translateToUseCppDeclarations | ( | SgNode * | n | ) |
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.
Definition at line 25257 of file sageInterface.C.
References SgNode::class_name(), SgScopeStatement::class_name(), and translateScopeToUseCppDeclarations().
void SageInterface::translateScopeToUseCppDeclarations | ( | SgScopeStatement * | scope | ) |
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.
Definition at line 25121 of file sageInterface.C.
References SgStatement::class_name(), SgScopeStatement::class_name(), SgScopeStatement::containsOnlyDeclarations(), SgLocatedNode::getAttachedPreprocessingInfo(), SgScopeStatement::getDeclarationList(), SgScopeStatement::getStatementList(), SgStatement::insert_statement(), skipTranslateToUseCppDeclaration(), and translateStatementToUseCppDeclarations().
Referenced by translateToUseCppDeclarations().
std::vector< SgC_PreprocessorDirectiveStatement * > SageInterface::translateStatementToUseCppDeclarations | ( | SgStatement * | statement, |
SgScopeStatement * | scope | ||
) |
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.
Definition at line 25089 of file sageInterface.C.
References SgLocatedNode::getAttachedPreprocessingInfo(), and skipTranslateToUseCppDeclaration().
Referenced by translateScopeToUseCppDeclarations().
void SageInterface::printOutComments | ( | SgLocatedNode * | locatedNode | ) |
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.
Definition at line 25021 of file sageInterface.C.
References SgLocatedNode::class_name(), and SgLocatedNode::getAttachedPreprocessingInfo().
Referenced by moveCommentsToNewStatement(), movePreprocessingInfo(), and replaceDefiningFunctionDeclarationWithFunctionPrototype().
bool SageInterface::skipTranslateToUseCppDeclaration | ( | PreprocessingInfo * | currentPreprocessingInfo | ) |
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.
Definition at line 25067 of file sageInterface.C.
Referenced by translateScopeToUseCppDeclarations(), and translateStatementToUseCppDeclarations().
void SageInterface::outputFileIds | ( | SgNode * | node | ) |
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.
Definition at line 24765 of file sageInterface.C.
References SgNode::class_name(), SgLocatedNode::class_name(), SgInitializedName::class_name(), SgLocatedNode::get_file_info(), SgNode::get_file_info(), and SgNode::get_isModified().
Referenced by SageBuilder::buildFile().
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.
Liao, 7/3/2008 Update a list of function declarations inside a scope according to a newly introduced one
Algorithm: iterate declaration list for the same functions func is defining: set_defining for all func is nondefining: is first ? set_first_nondefining for all not the first ? set first nondefining for itself only
Definition at line 15927 of file sageInterface.C.
References SgScopeStatement::class_name(), SgDeclarationStatement::class_name(), SgScopeStatement::containsOnlyDeclarations(), SgDeclarationStatement::get_definingDeclaration(), SgDeclarationStatement::get_firstNondefiningDeclaration(), SgStatement::get_scope(), SgScopeStatement::getDeclarationList(), SgScopeStatement::getStatementList(), isSameFunction(), SgDeclarationStatement::set_definingDeclaration(), and SgDeclarationStatement::set_firstNondefiningDeclaration().
Referenced by appendStatement(), insertStatement(), and prependStatement().
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++.
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++ This is a wrapper function to Qing's side effect analysis from loop optimization Liao, 2/26/2009 Returns true if the side effect analysis was complete, false otherwise. Note that a false result is expected if any functions are called in the body
Definition at line 22140 of file sageInterface.C.
References SgFunctionDefinition::get_body(), SgDeclarationStatement::get_definingDeclaration(), and getEnclosingFunctionDefinition().
Referenced by collectReadWriteVariables().
bool SageInterface::collectReadWriteVariables | ( | SgStatement * | stmt, |
std::set< SgInitializedName * > & | readVars, | ||
std::set< SgInitializedName * > & | writeVars, | ||
bool | coarseGrain = true |
||
) |
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. For accesses to members of aggregate data, we return the coarse grain aggregate mem obj by default.
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.
Definition at line 22246 of file sageInterface.C.
References collectReadWriteRefs(), and convertRefToInitializedName().
Referenced by collectReadOnlyVariables().
void SageInterface::collectReadOnlyVariables | ( | SgStatement * | stmt, |
std::set< SgInitializedName * > & | readOnlyVars, | ||
bool | coarseGrain = true |
||
) |
Collect read only variables within a statement. The statement can be either of a function, a scope, or a single line statement. For accesses to members of aggregate data, we return the coarse grain aggregate mem obj by default.
Collect read only variables within a statement. The statement can be either of a function, a scope, or a single line statement.
Definition at line 22284 of file sageInterface.C.
References RoseAst::begin(), collectReadWriteVariables(), RoseAst::end(), and isConstType().
Referenced by collectReadOnlySymbols().
void SageInterface::collectReadOnlySymbols | ( | SgStatement * | stmt, |
std::set< SgVariableSymbol * > & | readOnlySymbols, | ||
bool | coarseGrain = true |
||
) |
Collect read only variable symbols within a statement. The statement can be either of a function, a scope, or a single line statement. For accesses to members of aggregate data, we return the coarse grain aggregate mem obj by default.
Collect read only variable symbols within a statement. The statement can be either of a function, a scope, or a single line statement.
Definition at line 22312 of file sageInterface.C.
References collectReadOnlyVariables().
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++.
Definition at line 22329 of file sageInterface.C.
References SgNode::get_parent(), SgBinaryOp::get_rhs_operand_i(), and is_Cxx_language().
Referenced by collectUseByAddressVariableRefs().
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++.
Collect variable references involving use by address: including &a expression and foo(a) when foo(Type& parameter) in C++.
Definition at line 22408 of file sageInterface.C.
References SgNode::get_parent(), is_Cxx_language(), and isUseByAddressVariableRef().
LivenessAnalysis * SageInterface::call_liveness_analysis | ( | SgProject * | project, |
bool | debug = false |
||
) |
Call liveness analysis on an entire project.
Definition at line 22462 of file sageInterface.C.
References SgFunctionDefinition::class_name().
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.
Get liveIn and liveOut variables for a for loop.
Definition at line 22529 of file sageInterface.C.
void SageInterface::ReductionRecognition | ( | SgForStatement * | loop, |
std::set< std::pair< SgInitializedName *, OmpSupport::omp_construct_enum > > & | 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.
Definition at line 22923 of file sageInterface.C.
References SgForStatement::get_loop_body(), isAncestor(), isCanonicalForLoop(), and isScalarType().
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!
a wrapper for ConstantFolding::constantFoldingOptimization ()
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.
Definition at line 22994 of file sageInterface.C.
Referenced by forLoopNormalization(), loopCollapsing(), and loopTiling().
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 (with duplicated statement s) 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.
Definition at line 18259 of file sageInterface.C.
References appendStatement(), copyStatement(), SgFunctionDefinition::get_body(), insertStatementBefore(), and splitExpression().
void SageInterface::removeJumpsToNextStatement | ( | SgNode * | top | ) |
Remove jumps whose label is immediately after the jump. Used to clean up inlined code fragments.
Definition at line 11502 of file sageInterface.C.
References SgGotoStatement::get_label(), and SgBasicBlock::get_statements().
void SageInterface::removeUnusedLabels | ( | SgNode * | top, |
bool | keepChild = false |
||
) |
Remove labels which are not targets of any goto statements: its child statement is also removed by default.
Definition at line 11599 of file sageInterface.C.
References findUnusedLabels(), myRemoveStatement(), and replaceStatement().
std::set< SgLabelStatement * > SageInterface::findUnusedLabels | ( | SgNode * | top | ) |
Find unused labels which are not targets of any goto statements.
Definition at line 11563 of file sageInterface.C.
Referenced by removeUnusedLabels().
void SageInterface::removeConsecutiveLabels | ( | SgNode * | top | ) |
Remove consecutive labels.
Definition at line 13244 of file sageInterface.C.
References SgGotoStatement::get_label(), SgNode::get_parent(), SgBasicBlock::get_statements(), and SgGotoStatement::set_label().
bool SageInterface::mergeDeclarationAndAssignment | ( | SgVariableDeclaration * | decl, |
SgExprStatement * | assign_stmt, | ||
bool | removeAssignStmt = true |
||
) |
Merge a variable assignment statement into a matching variable declaration statement. Callers should make sure the merge is semantically correct (by not introducing compilation errors). This function simply does the merge transformation, without eligibility check.
e.g. int i; i=10; becomes int i=10; the original i=10 will be deleted after the merge if success, return true, otherwise return false (e.g. variable declaration does not match or already has an initializer) The original assignment stmt will be removed by default This function is a bit ambiguous about the merge direction, to be phased out.
Definition at line 13267 of file sageInterface.C.
References mergeAssignmentWithDeclaration().
bool SageInterface::mergeAssignmentWithDeclaration | ( | SgExprStatement * | assign_stmt, |
SgVariableDeclaration * | decl, | ||
bool | removeAssignStmt = true |
||
) |
Merge an assignment into its upstream declaration statement. Callers should make sure the merge is semantically correct.
Merge a variable assignment statement into a matching variable declaration statement.
e.g. int i; i=10; becomes int i=10; the original i=10 will be deleted after the merge if success, return true, otherwise return false (e.g. variable declaration does not match or already has an initializer)
Definition at line 13276 of file sageInterface.C.
References SageBuilder::buildAssignInitializer(), copyExpression(), SgBinaryOp::get_lhs_operand(), SgVariableSymbol::get_name(), SgBinaryOp::get_rhs_operand(), SgInitializedName::get_symbol_from_symbol_table(), getFirstInitializedName(), movePreprocessingInfo(), removeStatement(), and SgNode::set_parent().
Referenced by mergeDeclarationAndAssignment().
bool SageInterface::mergeDeclarationWithAssignment | ( | SgVariableDeclaration * | decl, |
SgExprStatement * | assign_stmt | ||
) |
Merge a declaration statement into a matching followed variable assignment. Callers should make sure the merge is semantically correct (by not introducing compilation errors). This function simply does the merge transformation, without eligibility check.
e.g. int i; i=10; becomes int i=10; the original int i; will be deleted after the merge
Definition at line 13330 of file sageInterface.C.
References SageBuilder::buildAssignInitializer(), copyExpression(), SgBinaryOp::get_lhs_operand(), SgVariableSymbol::get_name(), SgBinaryOp::get_rhs_operand(), SgInitializedName::get_symbol_from_symbol_table(), getFirstInitializedName(), getNextStatement(), insertStatementBefore(), movePreprocessingInfo(), removeStatement(), and SgNode::set_parent().
SgExprStatement * SageInterface::splitVariableDeclaration | ( | SgVariableDeclaration * | decl | ) |
Split a variable declaration with an rhs assignment into two statements: a declaration and an assignment.
Return the generated assignment statement, if any e.g. int i =10; becomes int i; i=10; This can be seen as a normalization of declarations
Definition at line 13403 of file sageInterface.C.
References SageBuilder::buildAssignStatement(), SageBuilder::buildVarRefExp(), deepCopy(), getFirstInitializedName(), and insertStatementAfter().
Referenced by splitVariableDeclaration().
ROSE_DLL_API int SageInterface::splitVariableDeclaration | ( | SgScopeStatement * | scope, |
bool | topLevelOnly = true |
||
) |
Split declarations within a scope into declarations and assignment statements, by default only top level declarations are considered. Return the number of declarations split.
Split declarations within a scope into declarations and assignment statements, by default only top level declarations are considered.
Definition at line 13430 of file sageInterface.C.
References SgStatement::get_scope(), and splitVariableDeclaration().
SgAssignInitializer * SageInterface::splitExpression | ( | SgExpression * | from, |
std::string | newName = "" |
||
) |
Replace an expression with a temporary variable and an assignment statement.
Merged from replaceExpressionWithStatement.C.
Add a new temporary variable to contain the value of 'from'. Change reference to 'from' to use this new variable. Assumptions: (1)'from' is not within the test of a loop or 'if'; (2)not currently traversing 'from' or the statement it is in. Return value: the new temp variable declaration's assign initializer containing the from expression.
Definition at line 13577 of file sageInterface.C.
References SageBuilder::buildAssignInitializer(), SageBuilder::buildVariableDeclaration(), SageBuilder::buildVarRefExp(), gensym_counter, SgConditionalExp::get_conditional_exp(), SgBinaryOp::get_lhs_operand(), SgNode::get_parent(), SgExpression::get_type(), getFirstVarSym(), isBodyStatement(), isCopyConstructible(), makeSingleStatementBodyToBlock(), replaceExpressionWithStatement(), SgNode::set_parent(), splitExpression(), and SgNode::unparseToString().
Referenced by instrumentEndOfFunction(), replaceSubexpressionWithStatement(), and splitExpression().
void SageInterface::splitExpressionIntoBasicBlock | ( | SgExpression * | expr | ) |
Split long expressions into blocks of statements.
This generalizes the normal splitExpression to allow loop tests and.
Definition at line 13670 of file sageInterface.C.
References SageBuilder::buildAssignStatement(), SageBuilder::buildBasicBlock(), and replaceExpressionWithStatement().
void SageInterface::removeLabeledGotos | ( | SgNode * | top | ) |
Remove labeled goto statements.
Definition at line 13683 of file sageInterface.C.
References SgGotoStatement::get_label(), SgNode::get_parent(), SgBasicBlock::get_statements(), and SgGotoStatement::set_label().
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.
Definition at line 16833 of file sageInterface.C.
References SageBuilder::buildBasicBlock(), SageBuilder::buildGotoStatement(), SageBuilder::buildLabelStatement(), findBreakStmts(), SgSwitchStatement::get_body(), SgNode::get_parent(), getLoopBody(), insertStatement(), Rose::StringUtility::numberToString(), SgStatement::replace_statement(), and SgNode::set_parent().
SgBasicBlock * SageInterface::ensureBasicBlockAsBodyOfFor | ( | SgForStatement * | fs | ) |
Check if the body of a 'for' statement is a SgBasicBlock, create one if not.
Definition at line 17246 of file sageInterface.C.
References SageBuilder::buildBasicBlock(), SgForStatement::get_loop_body(), recordNormalizations(), SgForStatement::set_loop_body(), and SgNode::set_parent().
Referenced by changeAllBodiesToBlocks(), forLoopNormalization(), and makeSingleStatementBodyToBlock().
SgBasicBlock * SageInterface::ensureBasicBlockAsBodyOfUpcForAll | ( | SgUpcForAllStatement * | fs | ) |
Check if the body of a 'upc_forall' statement is a SgBasicBlock, create one if not.
Definition at line 17291 of file sageInterface.C.
Referenced by changeAllBodiesToBlocks(), and makeSingleStatementBodyToBlock().
SgBasicBlock * SageInterface::ensureBasicBlockAsBodyOfWhile | ( | SgWhileStmt * | ws | ) |
Check if the body of a 'while' statement is a SgBasicBlock, create one if not.
Definition at line 17298 of file sageInterface.C.
References SageBuilder::buildBasicBlock(), SgWhileStmt::get_body(), recordNormalizations(), SgWhileStmt::set_body(), and SgNode::set_parent().
Referenced by changeAllBodiesToBlocks(), and makeSingleStatementBodyToBlock().
SgBasicBlock * SageInterface::ensureBasicBlockAsBodyOfDoWhile | ( | SgDoWhileStmt * | ws | ) |
Check if the body of a 'do .. while' statement is a SgBasicBlock, create one if not.
Definition at line 17312 of file sageInterface.C.
References SageBuilder::buildBasicBlock(), SgDoWhileStmt::get_body(), recordNormalizations(), SgDoWhileStmt::set_body(), and SgNode::set_parent().
Referenced by changeAllBodiesToBlocks(), and makeSingleStatementBodyToBlock().
SgBasicBlock * SageInterface::ensureBasicBlockAsBodyOfSwitch | ( | SgSwitchStatement * | ws | ) |
Check if the body of a 'switch' statement is a SgBasicBlock, create one if not.
Definition at line 17326 of file sageInterface.C.
References SageBuilder::buildBasicBlock(), SgSwitchStatement::get_body(), recordNormalizations(), SgSwitchStatement::set_body(), and SgNode::set_parent().
Referenced by changeAllBodiesToBlocks(), and makeSingleStatementBodyToBlock().
SgBasicBlock * SageInterface::ensureBasicBlockAsBodyOfCaseOption | ( | SgCaseOptionStmt * | cs | ) |
Check if the body of a 'case option' statement is a SgBasicBlock, create one if not.
Definition at line 17261 of file sageInterface.C.
References SageBuilder::buildBasicBlock(), SgCaseOptionStmt::get_body(), recordNormalizations(), SgCaseOptionStmt::set_body(), and SgNode::set_parent().
Referenced by makeSingleStatementBodyToBlock().
SgBasicBlock * SageInterface::ensureBasicBlockAsBodyOfDefaultOption | ( | SgDefaultOptionStmt * | cs | ) |
Check if the body of a 'default option' statement is a SgBasicBlock, create one if not.
Definition at line 17276 of file sageInterface.C.
References SageBuilder::buildBasicBlock(), SgDefaultOptionStmt::get_body(), recordNormalizations(), SgDefaultOptionStmt::set_body(), and SgNode::set_parent().
Referenced by makeSingleStatementBodyToBlock().
SgBasicBlock * SageInterface::ensureBasicBlockAsTrueBodyOfIf | ( | SgIfStmt * | ifs | ) |
Check if the true body of a 'if' statement is a SgBasicBlock, create one if not.
Definition at line 17340 of file sageInterface.C.
References SageBuilder::buildBasicBlock(), SgIfStmt::get_true_body(), recordNormalizations(), SgNode::set_parent(), and SgIfStmt::set_true_body().
Referenced by changeAllBodiesToBlocks(), and makeSingleStatementBodyToBlock().
SgBasicBlock * SageInterface::ensureBasicBlockAsFalseBodyOfIf | ( | SgIfStmt * | ifs, |
bool | createEmptyBody = true |
||
) |
Check if the false body of a 'if' statement is a SgBasicBlock, create one if not when the flag is true.
Definition at line 17553 of file sageInterface.C.
References SageBuilder::buildBasicBlock(), SgIfStmt::get_false_body(), recordNormalizations(), SgIfStmt::set_false_body(), and SgNode::set_parent().
Referenced by changeAllBodiesToBlocks(), and makeSingleStatementBodyToBlock().
SgBasicBlock * SageInterface::ensureBasicBlockAsBodyOfCatch | ( | SgCatchOptionStmt * | cos | ) |
Check if the body of a 'catch' statement is a SgBasicBlock, create one if not.
Definition at line 17570 of file sageInterface.C.
References SageBuilder::buildBasicBlock(), SgCatchOptionStmt::get_body(), SgCatchOptionStmt::set_body(), and SgNode::set_parent().
Referenced by changeAllBodiesToBlocks(), and makeSingleStatementBodyToBlock().
SgBasicBlock * SageInterface::ensureBasicBlockAsBodyOfOmpBodyStmt | ( | SgOmpBodyStatement * | ompbodyStmt | ) |
Check if the body of a SgOmpBodyStatement is a SgBasicBlock, create one if not.
Definition at line 17581 of file sageInterface.C.
References SageBuilder::buildBasicBlock(), and SgNode::set_parent().
Referenced by changeAllBodiesToBlocks(), and makeSingleStatementBodyToBlock().
void SageInterface::cleanupNontransformedBasicBlockNode | ( | ) |
Remove unused basic block IR nodes added as part of normalization.
Definition at line 17372 of file sageInterface.C.
References SgStatement::class_name(), SgIfStmt::class_name(), SgWhileStmt::get_body(), SgDoWhileStmt::get_body(), SgSwitchStatement::get_body(), SgCaseOptionStmt::get_body(), SgDefaultOptionStmt::get_body(), SgIfStmt::get_false_body(), SgNode::get_isModified(), SgForStatement::get_loop_body(), SgNode::get_parent(), SgBasicBlock::get_statements(), SgIfStmt::get_true_body(), SgWhileStmt::set_body(), SgDoWhileStmt::set_body(), SgSwitchStatement::set_body(), SgCaseOptionStmt::set_body(), SgDefaultOptionStmt::set_body(), SgIfStmt::set_false_body(), SgNode::set_isModified(), SgForStatement::set_loop_body(), SgNode::set_parent(), SgIfStmt::set_true_body(), and SgStatement::variantT().
void SageInterface::recordNormalizations | ( | SgStatement * | s | ) |
Record where normalization have been done so that we can preform denormalizations as required for the token-based unparsing to generate minimal diffs.
Definition at line 17358 of file sageInterface.C.
Referenced by ensureBasicBlockAsBodyOfCaseOption(), ensureBasicBlockAsBodyOfDefaultOption(), ensureBasicBlockAsBodyOfDoWhile(), ensureBasicBlockAsBodyOfFor(), ensureBasicBlockAsBodyOfSwitch(), ensureBasicBlockAsBodyOfWhile(), ensureBasicBlockAsFalseBodyOfIf(), and ensureBasicBlockAsTrueBodyOfIf().
int SageInterface::normalizeArrowExpWithAddressOfLeftOperand | ( | SgNode * | root, |
bool | transformationGeneratedOnly = true |
||
) |
Convert all code within root matching the patern of (&left)->right, and translate them into left.right. Return the number of matches of the pattern. Be default, only transformation generated nodes will be normalized.
Convert all code within root matching the patern of (&left)->right, and translate them into left.right. Return the number of matches of the pattern.
Definition at line 27513 of file sageInterface.C.
References SageBuilder::buildDotExp(), deepCopy(), SgExpression::get_file_info(), SgBinaryOp::get_lhs_operand(), SgBinaryOp::get_rhs_operand(), Sg_File_Info::isTransformation(), and replaceExpression().
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.
Definition at line 17593 of file sageInterface.C.
References SgNode::get_parent(), and SgLocatedNode::variantT().
Referenced by loopTiling(), makeSingleStatementBodyToBlock(), and splitExpression().
void SageInterface::changeAllBodiesToBlocks | ( | SgNode * | top, |
bool | createEmptyBody = true |
||
) |
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.
Definition at line 17869 of file sageInterface.C.
References SgNode::class_name(), ensureBasicBlockAsBodyOfCatch(), ensureBasicBlockAsBodyOfDoWhile(), ensureBasicBlockAsBodyOfFor(), ensureBasicBlockAsBodyOfOmpBodyStmt(), ensureBasicBlockAsBodyOfSwitch(), ensureBasicBlockAsBodyOfUpcForAll(), ensureBasicBlockAsBodyOfWhile(), ensureBasicBlockAsFalseBodyOfIf(), ensureBasicBlockAsTrueBodyOfIf(), SgNode::get_isModified(), SgNode::set_isModified(), and SgNode::variantT().
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.
Make a single statement body to be a basic block. Its parent is if, while, catch, or upc_forall.
Definition at line 17671 of file sageInterface.C.
References ensureBasicBlockAsBodyOfCaseOption(), ensureBasicBlockAsBodyOfCatch(), ensureBasicBlockAsBodyOfDefaultOption(), ensureBasicBlockAsBodyOfDoWhile(), ensureBasicBlockAsBodyOfFor(), ensureBasicBlockAsBodyOfOmpBodyStmt(), ensureBasicBlockAsBodyOfSwitch(), ensureBasicBlockAsBodyOfUpcForAll(), ensureBasicBlockAsBodyOfWhile(), ensureBasicBlockAsFalseBodyOfIf(), ensureBasicBlockAsTrueBodyOfIf(), SgNode::get_parent(), isBodyStatement(), and SgLocatedNode::variantT().
Referenced by loopTiling(), and splitExpression().
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.
Definition at line 18362 of file sageInterface.C.
References SgValueExp::class_name(), and SgValueExp::variantT().
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.
Please call this instead of calling getDependentDeclarations ( SgStatement* stmt, vector<SgDeclarationStatement*> & declarationList, vector<SgSymbol*> & symbolList )
Definition at line 19110 of file sageInterface.C.
References SgStatement::class_name(), getDependentDeclarations(), sortSgNodeListBasedOnAppearanceOrderInSource(), and AstSimpleProcessing::traverse().
Referenced by appendStatementWithDependentDeclaration(), and getDependentDeclarations().
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.
Insert an expression (new_exp )before another expression (anchor_exp) has possible side effects, with minimum changes to the original semantics. This is achieved by using a comma operator: (new_exp, anchor_exp). The comma operator is returned.
Definition at line 19909 of file sageInterface.C.
References SageBuilder::buildCommaOpExp(), SgNode::get_parent(), replaceExpression(), SgNode::set_parent(), and SgBinaryOp::set_rhs_operand().
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.
Insert an expression (new_exp ) after another expression (anchor_exp) has possible side effects, with minimum changes to 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.
Definition at line 19930 of file sageInterface.C.
References SageBuilder::buildAssignOp(), SageBuilder::buildCommaOpExp(), SageBuilder::buildVariableDeclaration(), SageBuilder::buildVarRefExp(), deepCopy(), gensym_counter, SgNode::get_parent(), SgStatement::get_scope(), SgExpression::get_type(), getEnclosingStatement(), getFirstVarSym(), insertStatementBefore(), Rose::StringUtility::numberToString(), and replaceExpression().
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
.
and an initialized name refering to the temporary variable holding the result of f
. In case f returns void the initialized name is NULL. definingDeclaration | the defining function declaration of f |
newName | the name of function f \details f's new body becomes { f (...); } and { int res = f<tt>(...); return res; } for functions returning void and a value, respectively. two function declarations are inserted in f's enclosing scope \code 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 f is the next entry in the statement list; the forward declaration of f` is the previous entry in the statement list. |
Referenced by wrapFunction().
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.
NameGen | functor that generates a new name based on the old name. interface: SgName nameGen(const SgName&) |
nameGen | name generator |
see wrapFunction for details
Definition at line 2657 of file sageInterface.h.
References wrapFunction().
SgInitializedName & SageInterface::getFirstVariable | ( | SgVariableDeclaration & | vardecl | ) |
convenience function that returns the first initialized name in a list of variable declarations.
Definition at line 23030 of file sageInterface.C.
References SgVariableDeclaration::get_variables().
bool SageInterface::hasTemplateSyntax | ( | const SgName & | name | ) |
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++.
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++ This is a wrapper function to Qing's side effect analysis from loop optimization Liao, 2/26/2009 Returns true if the side effect analysis was complete, false otherwise. Note that a false result is expected if any functions are called in the body
Definition at line 610 of file sageInterface.C.
Referenced by SageBuilder::buildClassDeclaration_nfi(), SageBuilder::buildDefiningClassDeclaration(), SageBuilder::buildNondefiningClassDeclaration(), SageBuilder::buildNondefiningClassDeclaration_nfi(), SageBuilder::buildNondefiningEnumDeclaration_nfi(), and SageBuilder::setTemplateNameInTemplateInstantiations().
set< unsigned int > SageInterface::collectSourceSequenceNumbers | ( | SgNode * | astNode | ) |
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++.
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++ This is a wrapper function to Qing's side effect analysis from loop optimization Liao, 2/26/2009 Returns true if the side effect analysis was complete, false otherwise. Note that a false result is expected if any functions are called in the body
Definition at line 23324 of file sageInterface.C.
References AstSimpleProcessing::traverse().
bool SageInterface::HasNoThrowAssign | ( | const SgType *const | inputType | ) |
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++.
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++ This is a wrapper function to Qing's side effect analysis from loop optimization Liao, 2/26/2009 Returns true if the side effect analysis was complete, false otherwise. Note that a false result is expected if any functions are called in the body
bool SageInterface::HasNoThrowCopy | ( | const SgType *const | inputType | ) |
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++.
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++ This is a wrapper function to Qing's side effect analysis from loop optimization Liao, 2/26/2009 Returns true if the side effect analysis was complete, false otherwise. Note that a false result is expected if any functions are called in the body
bool SageInterface::HasNoThrowConstructor | ( | const SgType *const | inputType | ) |
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++.
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++ This is a wrapper function to Qing's side effect analysis from loop optimization Liao, 2/26/2009 Returns true if the side effect analysis was complete, false otherwise. Note that a false result is expected if any functions are called in the body
bool SageInterface::HasTrivialAssign | ( | const SgType *const | inputType | ) |
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++.
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++ This is a wrapper function to Qing's side effect analysis from loop optimization Liao, 2/26/2009 Returns true if the side effect analysis was complete, false otherwise. Note that a false result is expected if any functions are called in the body
bool SageInterface::HasTrivialCopy | ( | const SgType *const | inputType | ) |
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++.
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++ This is a wrapper function to Qing's side effect analysis from loop optimization Liao, 2/26/2009 Returns true if the side effect analysis was complete, false otherwise. Note that a false result is expected if any functions are called in the body
bool SageInterface::HasTrivialConstructor | ( | const SgType *const | inputType | ) |
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++.
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++ This is a wrapper function to Qing's side effect analysis from loop optimization Liao, 2/26/2009 Returns true if the side effect analysis was complete, false otherwise. Note that a false result is expected if any functions are called in the body
bool SageInterface::HasTrivialDestructor | ( | const SgType *const | inputType | ) |
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++.
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++ This is a wrapper function to Qing's side effect analysis from loop optimization Liao, 2/26/2009 Returns true if the side effect analysis was complete, false otherwise. Note that a false result is expected if any functions are called in the body
bool SageInterface::HasVirtualDestructor | ( | const SgType *const | inputType | ) |
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++.
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++ This is a wrapper function to Qing's side effect analysis from loop optimization Liao, 2/26/2009 Returns true if the side effect analysis was complete, false otherwise. Note that a false result is expected if any functions are called in the body
bool SageInterface::IsBaseOf | ( | const SgType *const | inputBaseType, |
const SgType *const | inputDerivedType | ||
) |
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++.
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++ This is a wrapper function to Qing's side effect analysis from loop optimization Liao, 2/26/2009 Returns true if the side effect analysis was complete, false otherwise. Note that a false result is expected if any functions are called in the body
bool SageInterface::IsAbstract | ( | const SgType *const | inputType | ) |
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++.
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++ This is a wrapper function to Qing's side effect analysis from loop optimization Liao, 2/26/2009 Returns true if the side effect analysis was complete, false otherwise. Note that a false result is expected if any functions are called in the body
bool SageInterface::IsEmpty | ( | const SgType *const | inputType | ) |
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++.
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++ This is a wrapper function to Qing's side effect analysis from loop optimization Liao, 2/26/2009 Returns true if the side effect analysis was complete, false otherwise. Note that a false result is expected if any functions are called in the body
bool SageInterface::IsEnum | ( | const SgType *const | inputType | ) |
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++.
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++ This is a wrapper function to Qing's side effect analysis from loop optimization Liao, 2/26/2009 Returns true if the side effect analysis was complete, false otherwise. Note that a false result is expected if any functions are called in the body
bool SageInterface::IsPod | ( | const SgType *const | inputType | ) |
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++.
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++ This is a wrapper function to Qing's side effect analysis from loop optimization Liao, 2/26/2009 Returns true if the side effect analysis was complete, false otherwise. Note that a false result is expected if any functions are called in the body
bool SageInterface::IsPolymorphic | ( | const SgType *const | inputType | ) |
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++.
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++ This is a wrapper function to Qing's side effect analysis from loop optimization Liao, 2/26/2009 Returns true if the side effect analysis was complete, false otherwise. Note that a false result is expected if any functions are called in the body
bool SageInterface::IsStandardLayout | ( | const SgType *const | inputType | ) |
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++.
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++ This is a wrapper function to Qing's side effect analysis from loop optimization Liao, 2/26/2009 Returns true if the side effect analysis was complete, false otherwise. Note that a false result is expected if any functions are called in the body
bool SageInterface::IsLiteralType | ( | const SgType *const | inputType | ) |
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++.
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++ This is a wrapper function to Qing's side effect analysis from loop optimization Liao, 2/26/2009 Returns true if the side effect analysis was complete, false otherwise. Note that a false result is expected if any functions are called in the body
bool SageInterface::IsTrivial | ( | const SgType *const | inputType | ) |
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++.
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++ This is a wrapper function to Qing's side effect analysis from loop optimization Liao, 2/26/2009 Returns true if the side effect analysis was complete, false otherwise. Note that a false result is expected if any functions are called in the body
bool SageInterface::IsUnion | ( | const SgType *const | inputType | ) |
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++.
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++ This is a wrapper function to Qing's side effect analysis from loop optimization Liao, 2/26/2009 Returns true if the side effect analysis was complete, false otherwise. Note that a false result is expected if any functions are called in the body
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++.
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++ This is a wrapper function to Qing's side effect analysis from loop optimization Liao, 2/26/2009 Returns true if the side effect analysis was complete, false otherwise. Note that a false result is expected if any functions are called in the body
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++.
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++ This is a wrapper function to Qing's side effect analysis from loop optimization Liao, 2/26/2009 Returns true if the side effect analysis was complete, false otherwise. Note that a false result is expected if any functions are called in the body
Definition at line 23661 of file sageInterface.C.
References RoseAst::begin(), and RoseAst::end().
Referenced by SageBuilder::fixupCopyOfAstFromSeparateFileInNewTargetAst().
struct SageInterface::const_int_expr_t SageInterface::evaluateConstIntegerExpression | ( | SgExpression * | expr | ) |
The function tries to evaluate const integer expressions (such as are used in array dimension sizes). It follows variable symbols, and requires constness.
Definition at line 24477 of file sageInterface.C.
References AstBottomUpProcessing< SynthesizedAttributeType >::traverse().
Referenced by checkTypesAreEqual().
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++.
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++ This is a wrapper function to Qing's side effect analysis from loop optimization Liao, 2/26/2009 Returns true if the side effect analysis was complete, false otherwise. Note that a false result is expected if any functions are called in the body
Definition at line 24483 of file sageInterface.C.
References RoseAst::begin(), RoseAst::end(), evaluateConstIntegerExpression(), SgFunctionParameterTypeList::get_arguments(), SgFunctionType::get_arguments(), SgNamedType::get_qualified_name(), SgModifierType::get_typeModifier(), isRestrictType(), isVolatileType(), SgType::stripType(), and SgNode::variantT().
string SageInterface::getTempDirectory | ( | SgProject * | project | ) |
Create a temporary directory if it does not yet exist and return its name.
Definition at line 23875 of file sageInterface.C.
void SageInterface::destroyTempDirectory | ( | std::string | directory_name | ) |
Use the system command to remove a temporary directory and all its containing files.
Definition at line 23894 of file sageInterface.C.
SgFile * SageInterface::processFile | ( | SgProject * | project, |
std::string | filename, | ||
bool | unparse = false |
||
) |
Invoke JavaRose to translate a given file and put the resulting AST in the global space of the project.
Definition at line 23904 of file sageInterface.C.
References CommandlineProcessing::generateSourceFilenames(), and CommandlineProcessing::removeAllFileNamesExcept().
Referenced by preprocessCompilationUnit(), preprocessImport(), and preprocessPackage().
string SageInterface::preprocessPackage | ( | SgProject * | project, |
std::string | package_name | ||
) |
Using the package_name, create a file with a package statement, translate it in order to load the package into the project.
Definition at line 23943 of file sageInterface.C.
References processFile().
Referenced by findOrInsertJavaPackage().
string SageInterface::preprocessImport | ( | SgProject * | project, |
std::string | import_string | ||
) |
Using the import_string parameter, create a file with the relevant import statement; translate the file and add its AST to the project.
Definition at line 23968 of file sageInterface.C.
References processFile().
Referenced by findOrImportJavaClass().
SgFile * SageInterface::preprocessCompilationUnit | ( | SgProject * | project, |
std::string | file_name, | ||
std::string | file_content, | ||
bool | unparse = true |
||
) |
Using the file_content string, create a file with the content in question; build its AST and add it to the project.
Definition at line 23993 of file sageInterface.C.
References processFile().
SgClassDefinition * SageInterface::findJavaPackage | ( | SgScopeStatement * | scope, |
std::string | package_name | ||
) |
Look for a qualified package name in the given scope and return its package definition.
Definition at line 24014 of file sageInterface.C.
Referenced by findOrInsertJavaPackage().
SgClassDefinition * SageInterface::findOrInsertJavaPackage | ( | SgProject * | project, |
std::string | package_name, | ||
bool | create_directory = false |
||
) |
Process a qualified package name, if needed, and return its package definition.
Definition at line 24047 of file sageInterface.C.
References findJavaPackage(), and preprocessPackage().
Referenced by findOrImportJavaClass().
SgClassDeclaration * SageInterface::findOrImportJavaClass | ( | SgProject * | project, |
SgClassDefinition * | package_definition, | ||
std::string | class_name | ||
) |
If the class_name already exists in the scope, return it.
Otherwise, import it.
Definition at line 24071 of file sageInterface.C.
References preprocessImport().
Referenced by findOrImportJavaClass(), and findOrImportJavaClass().
SgClassDeclaration * SageInterface::findOrImportJavaClass | ( | SgProject * | project, |
std::string | package_name, | ||
std::string | class_name | ||
) |
If the class_name already exists in the scope, return it.
Otherwise, import it.
Definition at line 24094 of file sageInterface.C.
References findOrImportJavaClass(), and findOrInsertJavaPackage().
SgClassDeclaration * SageInterface::findOrImportJavaClass | ( | SgProject * | project, |
SgClassType * | class_type | ||
) |
If the class_name already exists in the scope, return it.
Otherwise, import it.
Definition at line 24102 of file sageInterface.C.
References findOrImportJavaClass(), and get_name().
SgMemberFunctionDeclaration * SageInterface::findJavaMain | ( | SgClassDefinition * | class_definition | ) |
Find a main method in a Java class.
Definition at line 24124 of file sageInterface.C.
References SageBuilder::buildFunctionParameterTypeList(), SageBuilder::buildMemberFunctionType(), SgTypeVoid::createType(), and SageBuilder::getUniqueJavaArrayType().
Referenced by findJavaMain().
SgMemberFunctionDeclaration * SageInterface::findJavaMain | ( | SgClassType * | class_type | ) |
Find a main method in a Java class.
Definition at line 24145 of file sageInterface.C.
References findJavaMain().
bool SageInterface::isTemplateInstantiationFromTemplateDeclarationSatisfyingFilter | ( | SgFunctionDeclaration * | function, |
T * | filter | ||
) |
This function detects template instantiations that are relevant when filters are used.
EDG normalizes some in-class template functions and member functions to be redefined outside of a class. this causes the associated template instantiations to be declared outside of the class, and to be marked as compiler generated (since the compiler generated form outside of the class declaration). ROSE captures the function definitions, but in the new location (defined outside of the class declaration). This can confuse some simple tests for template instantiations that are a part of definitions in a file, thus we have this function to detect this specific normalization.
Definition at line 2996 of file sageInterface.h.
References SgFunctionDeclaration::class_name(), SgDeclarationStatement::get_firstNondefiningDeclaration(), SgTemplateInstantiationMemberFunctionDecl::get_templateDeclaration(), and SgTemplateInstantiationFunctionDecl::get_templateDeclaration().
void SageInterface::detectCycleInType | ( | SgType * | type, |
const std::string & | from | ||
) |
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++.
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++ This is a wrapper function to Qing's side effect analysis from loop optimization Liao, 2/26/2009 Returns true if the side effect analysis was complete, false otherwise. Note that a false result is expected if any functions are called in the body
Definition at line 26664 of file sageInterface.C.
References SgType::class_name(), and SgTypedefType::get_base_type().
void SageInterface::checkForInitializers | ( | SgNode * | node | ) |
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++.
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++ This is a wrapper function to Qing's side effect analysis from loop optimization Liao, 2/26/2009 Returns true if the side effect analysis was complete, false otherwise. Note that a false result is expected if any functions are called in the body
Definition at line 27409 of file sageInterface.C.
References SgExpression::class_name(), and getFirstInitializedName().
void SageInterface::clearSharedGlobalScopes | ( | SgProject * | project | ) |
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++.
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++ This is a wrapper function to Qing's side effect analysis from loop optimization Liao, 2/26/2009 Returns true if the side effect analysis was complete, false otherwise. Note that a false result is expected if any functions are called in the body
Definition at line 27477 of file sageInterface.C.
References SgFunctionTypeTable::get_function_type_table(), SgNode::get_globalFunctionTypeTable(), SgNode::get_globalTypeTable(), and SgScopeStatement::get_symbol_table().
void SageInterface::setSourcePositionToDefault | ( | T * | node | ) |
Definition at line 7115 of file sageInterface.C.
Transformation_Record SageInterface::trans_records |
Definition at line 138 of file sageInterface.C.
|
extern |
An internal counter for generating unique SgName.
Definition at line 592 of file sageInterface.C.
Referenced by addStepToLoopBody(), insertAfterUsingCommaOp(), loopUnrolling(), normalizeForLoopInitDeclaration(), and splitExpression().
|
extern |
Global map of name collisions to support generateUniqueNameForUseAsIdentifier() function.
Definition at line 130 of file sageInterface.C.
Referenced by computeUniqueNameForUseAsIdentifier(), generateUniqueNameForUseAsIdentifier_support(), and reset_name_collision_map().
|
extern |
Global map of name collisions to support generateUniqueNameForUseAsIdentifier() function.
Definition at line 131 of file sageInterface.C.
Referenced by computeUniqueNameForUseAsIdentifier(), generateUniqueNameForUseAsIdentifier(), and reset_name_collision_map().
|
extern |
Global map of name collisions to support generateUniqueNameForUseAsIdentifier() function.
Definition at line 132 of file sageInterface.C.
Referenced by computeUniqueNameForUseAsIdentifier(), generateUniqueNameForUseAsIdentifier(), and reset_name_collision_map().
vector<SgBasicBlock*> SageInterface::addedBasicBlockNodes |
Definition at line 153 of file sageInterface.C.