SgNodeHelper
Namespaces
Name |
Description |
Provides functions which match a certain AST pattern and return a pointer to a node of interest inside that pattern. |
Types
Name |
Description |
Result structure of extended C++ function call matching |
|
Functions for simplifying access to SgNode information |
|
collects all pragmas with name 'pragmaName' and creates a list of all pragma strings (with stripped off prefix) and the associated SgNode. |
Functions
Name |
Description |
|
returns location (consisting of filename, line, column) Abbreviates fileName if too long, max file name length can be set |
|
computes a list representing the nesting structure of classes (including structs and unions). It traverses the AST upwards and collects SgClassDeclaration(s) only. This covers nested classes, nested structs, and nested unions, and combinations of those. |
|
|
|
this function should only be called for a node in the subtree of a SgFunctionDefinition node. For a given 'node' it determines the correspondnig functionDefinition node when searching upwards in the AST for such a SgFunctionDefinition node. It is useful as a simple lookup function from inside the AST subtree of a SgFunctionDefinition. Returns 0 if no SgFunctionDefinition is found (e.g. global scope). |
|
computes for a given node the index number of it from the parent. e.g. node1(node2,node3,node4) : node4 has index 2 (starting at 0) For the root node of an AST (e.g. SgProject) this function returns ‐1. |
|
This function determines for a given function‐call‐expression its corresponding function‐definition (by using get_definingDeclaration). This function has constant complexity. It does not perform a search, but uses the information as present in the AST. If this information is not sufficient to determine the definition of a function it returns 0. For a consistent AST this will find all definitions in the same file, but not in a other SgFile. |
|
determines all VarRefExp in the subtree of 'node'. The order in the vector corresponds to the traversal order on the AST. |
|
Same as doubleQuotedEscapedString but also replaces <,<=,>=,> with the corresponding HTML codes. This is required when printing program code inside HTML tables of a dot file. |
|
computes a new string from s1 where each doublequote is replaced with a backslash followed by the doublequote. This is helpful when printing unparsed program fragments which contain doublequoted strings to a dot file (used by nodeToString). This function also replaces <,<=,>=,> with the corresponding HTML codes. |
|
returns the function declaration statement found for a given function symbol. |
|
returns the declaration statement found for a given variable symbol. |
|
|
|
|
|
schroder3 (2016‐07‐22): Returns the closest function definition that contains the given node |
|
returns the root node representing the AST of the condition of If, While, DoWhile, For, CondOperator, switch. |
|
returns the child of SgExpressionRoot (which is guaranteed to be unique and to exist) |
|
returns the child of SgExprStatement (which is guaranteed to be unique and to exist) |
|
returns the root node representing the AST of the false branch of If, CondOperator. |
|
returns the first child of an arbitrary AST node (throws exception if numChildren==0) |
|
returns the first Statement of SgBasicBlock (throws exception if numChildren==0) |
|
returns the incr/derc‐expr of For. |
|
returns the initializer‐list of For. |
|
return a function‐call's argument list |
|
return a function‐definition's list of formal paramters |
|
returns function name of SgFunctionDefinition, SgFunctionDeclaration, SgFunctionCall. |
|
return a function‐definition's return type |
|
returns the initialized name object of a variable declaration. Otherwise it throws an exception. |
|
returns the initializer expression of a variable declaration. If no initializer exists it returns 0. |
|
|
|
returns the label name of a SgLabelStatement without trailing ":" |
|
returns the last Statement of SgBasicBlock (throws exception if numChildren==0) |
|
return lhs of a binary node (if it is not a binary node it throws an exception) |
|
returns the root node representing the AST of the loop body of While, DoWhile, For. |
|
|
|
returns the parent of a node. Essentially a wrapper function of the ROSE get_parent() function, but throws an exception if no parent exists. For SgProject node no exception is thrown if no parent exists because it is the root node of a ROSE AST. |
|
return the verbatim pragma string as it is found in the source code this string includes the leading "#pragma". |
|
|
|
return rhs of a binary node (if it is not a binary node it throws an exception) |
|
returns the SgSymbol* of the function in a SgFunctionRefExp |
|
returns the SgSymbol* of the variable in a function declaration |
|
returns the SgSymbol* of a SgInitializedName |
|
returns the SgSymbol* of the variable in a SgVarRefExp |
|
returns the SgSymbol* of the variable in a variable declaration |
|
returns the root node representing the AST of the true branch of If, CondOperator. |
|
returns the child of a SgUnaryExp (which is guaranteed to be unique and to exist) |
|
returns true if the declaration has an assign initializer (e.g. char[2]="";) |
|
Checks if an OpenMP construct is marked with a nowait clause |
|
|
|
returns true if the declaration has an initializer list (e.g. char[2]={'a',0}; |
|
|
|
|
|
checks whether the expression 'node' represents an assignment to an array's element considers all assignment operators and arrays of any size |
|
checks whether the node 'node' is the root node of the AST by using the get_parent function. |
|
|
|
|
|
is true if 'node' is the root node of the AST representing the condition of If, While, DoWhile, For, switch, CondExp. |
|
is true if 'node' is the root node of the AST representing the condition of If, While, DoWhile, For, switch. |
|
is true if 'node' is the root node of the AST representing If, While, DoWhile, For, switch. |
|
is true if 'node' is the root node of the AST representing If, While, DoWhile, For, switch, CondExp. |
|
|
|
|
|
determines whether a node is the root node of an AST representing the inc‐expr in a SgForStatement. This function is helpful to deal with this special case in the ROSE AST where an expression does not have a root node which can be easily determined to be a root node of an expression (i.e. here it can be any binary or unary node in constrast to all other expressions in the ROSE AST which are either a SgExprStatement or have a SgExpressionRoot node. |
|
Determines whether a provided function declaration is a forward declaration |
|
checks whether a SgVariableSymbol is representing a function parameter (this does not apply for forward declarations) |
|
|
|
|
|
Determines if a variable is declared in global name space |
|
checks whether 'elem' is the last child (in traversal order) of node 'parent'. |
|
is true if 'node' is the root node of the AST representing the condition of a Loop construct (While, DoWhile, For). |
|
is true if 'node' is the root node of the AST representing a Loop construct (While, DoWhile, For). |
|
|
|
|
|
|
|
returns true for Expr‐‐ and Expr‐‐, otherwise false; |
|
checks whether prefix 'prefix' is a prefix in string 's'. |
|
returns true for ‐‐Expr and ++Expr, otherwise false. |
|
|
|
|
|
|
|
checks whether a SgVariableSymbol is representing a variable in |
|
returns line, column, and unparsed node in one string. |
|
|
|
returns a std::pair of line and column number. If no file info exists at this node it returns (‐1,‐1). |
|
|
|
|
|
|
|
identifies the list of SgFunctionDefinitions in global scope Functions/methods of classes are NOT included in this list. Note: static/external can be resolved by further processing those objects |
|
identifies the list of global variables Note: static/external can be resolved by further processing those objects |
|
searches in the provided Project for SgGlobal nodes |
|
|
|
returns the set of all local variable‐declarations of a function |
|
returns location (consisting of filename, line, column) and source code of unparsed node in one string. Abbreviates fileName and unparsed source if too long (defaults are 30,20) |
|
returns location (consisting of filename, line, column) |
|
returns a set of SgNode where each node is a break node, but properly excludes all nested loops. |
|
|
|
matches C and C++ function calls (also ctor and dtor) |
|
Returns for a given class/struct/union a list with the variable declarations of the member variables. Note this is a filtered list returned by the SgType::returnDataMemberPointers function which also returns pointers to methods |
|
|
|
returns a string representing the node (excluding the subtree) |
|
returns the number of children as int (intentionally not as t_size) ensures that the number of children fits into an int, otherwise throws exception. |
|
replaces the ast with root 'node' with the string 's'. The string is attached to the AST and the unparser uses string s instead of unparsing this substree. This function can be used to generate C++ extensions. |
|
replaces expression e1 by expression e2. Currently it uses the SageInterface::rewriteExpression function but wraps around some addtional checks that significantly improve performance of the replace operation. |
|
replace in string 'str' each string 'from' with string 'to'. |
|
computes for a given node at which scope nesting level this node is in its AST |
|
computes for a given node at which scope nesting level this node is in its AST |
|
sets 'cond' as the root node of the AST representing the condition in statements if, while, dowhile, for, switch. |
|
returns filename+line+column information of AST fragment in format "filename:line:column". Used for generating readable output |
|
returns filename as stored in AST node. Used for generating readable output. |
|
|
|
|
|
collects all case labels from the switch it started in (excludes nested switch stmts). This function also works for Duff's device code where 'case' labels can be inside nested loop/if constructs. |
|
returns the default stmt if it exists. Otherwise return 0 and can be used to test whether a default stmt exists in a given switch stmt. This function also works for Duff's device code. code where 'default' labels can be inside nested loop/if constructs. |
|
returns name of symbol as string |
|
Creates a long unique variable name for a given node of type SgVariableDeclaration or SgVarRefExp |
|
returns the string representing the condition (removes trailing ';') |
Created with MrDocs