Skip to content

SgLocatedNode

This class represents the notion of an expression or statement which

Synopsis

Declared in <src/frontend/SageIII/Cxx_Grammar.h>

class SgLocatedNode
    : public SgNode

Base Classes

Name

Description

SgNode

This class represents the base class for all IR nodes within Sage III.

Friends

Name

Description

isSgLocatedNode

Casts pointer from base class to derived class (for const pointers)

isSgLocatedNode

Casts pointer from base class to derived class

Non-Member Functions

Name

Description

checkPhysicalSourcePosition

Checks whether the physical source position information is consistant in the Sg_File_Info object

checkTransformedFlagsVisitor

Check for consistancy of isTransformation flags for nodes marked as a transformation.

cleanupInlinedCode

Combined procedure for cleaning up code after inlining. Does not do variable renaming or block flattening, however.

detectTransformations

Detect nodes marked as transformations (should not be present coming out of the frontend translation).

findVariablesUsedInRegion

Find all variables referenced in a region

fixReturnStatements

Workaround for ROSE bug. Should be used whenever expressions in a program are modified.

flattenBlocks

Flatten nested blocks of code in a program. This code requires that variable names in the region being processed are already distinct, and it may extend variable lifetimes to the end of the outer block of code.

getStatementOfExpression

Get the statement of an expression. Somewhat smarter than the standard version of this routine, but needs to be merged.

isMemberVariable

Internal routine to check whether a given variable declaration is a member variable.

isSgExpression

Casts pointer from base class to derived class (for const pointers)

isSgExpression

Casts pointer from base class to derived class

isSgInitializedName

Casts pointer from base class to derived class (for const pointers)

isSgInitializedName

Casts pointer from base class to derived class

isSgStatement

Casts pointer from base class to derived class

isSgStatement

Casts pointer from base class to derived class (for const pointers)

markLhsValues

Mark relavant expressions as l‐values explicitly.

moveForDeclaredVariables

Move variables declared in a for statement to just outside that statement.

propagateHiddenListData

Propagate hidden list information for variables, types, and class elaboration.

rebindVariableAndLabelReferences

Change all variable and label references to point to new symbols, created to point to the matching declaration found in the program. This needs to be moved into somewhere in FixSgTree.

removeNullStatements

Remove all null statements (those with only an integer constant or a null expression)

removeUnusedVariables

Remove unused variables in a scope

renameLabels

Rename all labels in a block of code.

renameVariables

Rename all variables in a block of code, and ensure that all variable references point to the correct declarations.

replaceChild

Replace a child of a node.

simpleCopyAndConstantPropagation

In code with declarations such as "int foo = bar", where foo and bar are not modified, replace "foo" with "bar" and remove the declaration

simpleIndexFiniteDifferencing

Do a simple form of finite differencing on all functions contained within root (which should be a project, file, or function definition).

topLevelValidateParentPointers

This is a top level function not called recursively.

validateFreshSubtreeOwnership

Validate a fresh detached construction transaction.

validateParentPointers

Validate exact parent ownership for a published AST.

validateParentPointersOfClassOrNamespaceDeclarations

This is a top level function not called recursively.

ASTtools::deepCopy

Create a deep‐copy of an SgNode

ASTtools::isC99

Returns 'true' if this node is contained in a C99‐only project.

ASTtools::setSourcePositionAsTransformation

Reset source position as transformation for the current node only

ASTtools::setSourcePositionAtRootAndAllChildrenAsTransformation

Reset source position as transformation recursively

ASTtools::toStringFileLoc

Convert a node's location to a string‐friendly form.

AstQueryNamespace::querySubTree

**** The function Result querySubTree ( SgNode * subTree, _Result (__x)(SgNode_,_Arg), Arg x_arg, AstQueryNamespace::QueryDepth defineQueryType =AstQueryNamespace::AllNodes ) will query the subtree of the IR node in the first argument for nodessatisfying the criteria specified in and returned by the function pointer inthe second argument.**

AstQueryNamespace::querySubTree

** The function Result querySubTree ( SgNode * subTree, _Result (__x)(SgNode_), AstQueryNamespace::QueryDepth defineQueryType =AstQueryNamespace::AllNodes )* will query the subtree of the IR node in the first argument for nodessatisfying the criteria specified in and returned by the function pointer inthe second argument.**

AstQueryNamespace::querySubTree

**** The function std::list<ListElement> querySubTree<ListElement>(SgNode* node,Predicate& _pred) will query the subtree of the IR node in the first argumentfor nodes satisfying the criteria specified in and returned by the predicatein the second argument.**

AstUtilInterface::CollectSideEffectVariables

Collect non‐local variables that are read and written within the given ast. This is a wrapper of the ComputeAstSideEffects function to provide a more convenient user interface. Returns true if the returned variables are guaranteed to be complete; returns false otherwise.

AstUtilInterface::ComputeAstSideEffects

Returns the collection of memory references modified, read, and invoked (as function calls) as potential side effects of running the given ast, inside the given scope.

CPreproc::extractIfDirectives

Extracts the '#if' directive structure from a project.

CPreproc::findIfDirectiveContext

Locate the '#if' directive context at a node.

CallTargetSet::solveFunctionPointerCallsFunctional

Checks if the functionDeclaration (node) matches functionType

ConstantFolding::constantFoldingOptimization

This is the external interface of constant folding:

NameQuery::querySubTree

****

NameQuery::querySubTree

****

NameQuery::querySubTree

****

NameQuery::querySubTree

****

NodeQuery::queryMemoryPool

** The function NodeQuerySynthesizedAttributeType queryMemoryPool ( SgNode * subTree, Result (*x)(SgNode*,_Arg), Arg x_arg, VariantVector ){ will on every node of the memory pool which has a corresponding variant inVariantVector performa the action specified by the second argument and returna NodeQuerySynthesizedAttributeType.*

NodeQuery::queryMemoryPool

** The function Result queryMemoryPool ( SgNode * subTree, SgNode, TypeOfQueryTypeTwoParameters, VariantVector* ){ will on every node of the memory pool which has a corresponding variant inVariantVector performa the predefined action specified by the second argumentand return a NodeQuerySynthesizedAttributeType.**

NodeQuery::queryMemoryPool

** The function Result queryMemoryPool ( SgNode * subTree, _Result (__x)(SgNode_), VariantVector* ){ will on every node of the memory pool which has a corresponding variant inVariantVector performa the action specified by the second argument and returna NodeQuerySynthesizedAttributeType.**

NodeQuery::querySubTree

****

NodeQuery::querySubTree

****

NodeQuery::querySubTree

****

NodeQuery::querySubTree

The function querySubTree (SgNode * subTree, VariantVector targetVariantVector, AstQueryNamespace::QueryDepth defineQueryType =AstQueryNamespace::AllNodes); reutnrs a list of all SgNodes us the ASTsub‐tree of the variable 'subTree' conforming to the variants inVariantVector.*****

NodeQuery::querySubTree

****

NodeQuery::querySubTree

****

NodeQuery::querySubTree

****

NumberQuery::querySubTree

****

NumberQuery::querySubTree

****

NumberQuery::querySubTree

****

NumberQuery::querySubTree

****

OmpSupport::generateOutlinedTask

A helper function to generate implicit or explicit task for either omp parallel or omp task

OmpSupport::getEnclosingRegionOrFuncDefinition

Find an enclosing parallel region or function definition's body

OmpSupport::isOmpContextSelectorMetadataDirective

Return true when an OpenMP statement is a syntax‐only construct selector owned by a MATCH/WHEN clause rather than an executable AST statement.

OmpSupport::replaceVariableReferences

Replace references to oldVar within root with references to newVar, return the number of references replaced.

OmpSupport::replaceVariableReferences

Replace variable references within root based on a map from old symbols to new symbols

OmpSupport::replaceVariablesWithPointerDereference

Replace all variable references in a set by pointers to the variable

OmpSupport::transOmpAtomic

Translate omp atomic

OmpSupport::transOmpBarrier

Translate omp barrier

OmpSupport::transOmpCritical

Translate omp critical

OmpSupport::transOmpFlush

Translate omp flush

OmpSupport::transOmpLoop

Translate omp for or omp do loops

OmpSupport::transOmpMaster

Translate omp master

OmpSupport::transOmpMetadirective

Translate omp metadirective

OmpSupport::transOmpOrdered

Translate the ordered directive (not the ordered clause)

OmpSupport::transOmpParallel

Translate omp parallel

OmpSupport::transOmpSections

Translate omp sections

OmpSupport::transOmpSimd

Translate omp simd

OmpSupport::transOmpSingle

Translate omp single

OmpSupport::transOmpTarget

Translate "omp target"

OmpSupport::transOmpTargetData

Translate "omp target data"

OmpSupport::transOmpTargetLoop

Translate omp for or omp do loops affected by the "omp target" directive, using naive 1‐to‐1 mapping Liao 1/28/2013

OmpSupport::transOmpTargetLoop_RoundRobin

Translate omp for or omp do loops affected by the "omp target" directive, using a round robin‐scheduler Liao 7/10/2014

OmpSupport::transOmpTargetParallel

Translate omp parallel under "omp target"

OmpSupport::transOmpTask

Translate omp task

OmpSupport::transOmpTaskwait

Translate omp taskwait

OmpSupport::transOmpThreadprivate

Translate omp threadprivate

OmpSupport::transOmpTile

Translate omp tile

OmpSupport::transOmpUnroll

Translate omp unroll

ProcessExpression::processLHS

Helper Function to process Left Hand Side of an Expression

ProcessExpression::processRHS

Helper Function to process Right Hand Side of an Expression

SageBuilder::buildComment

Build and attach a comment with an explicit lexical comment style. It is a wrapper of SageInterface::attachComment().

SageBuilder::buildCpreprocessorDefineDeclaration

Build and attach #define XX directives, pass "#define xxx xxx" as content.

SageBuilder::errorCheckingTargetAST

Error checking the inserted snippet AST.

SageBuilder::fixupSharingSourcePosition

Sharing IR nodes requires that the file id be added to the fileIDsToUnparse held in the Sg_File_Info object.

SageBuilder::requireFreshNfiLocatedNodeSourceState

Enforce the construction‐time contract shared by all expression builders whose names end in _nfi: the newly allocated root must not already own any source‐position object. This validator never clears or repairs provenance.

SageInterface::addVarRefExpFromArrayDimInfo

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

SageInterface::astIntersection

Compute the intersection set for two ASTs.

SageInterface::attachComment

Build and attach a comment with an explicit lexical comment style.

SageInterface::changeAllBodiesToBlocks

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.

SageInterface::collectModifiedLocatedNodes

This collects the SgLocatedNodes that are marked as modified (a flag automatically set by all set_* generated functions) (useful in debugging).

SageInterface::collectModifiedStatements

This collects the statements that are marked as modified (a flag automatically set by all set_* generated functions) (useful in debugging).

SageInterface::collectTransformedStatements

This collects the statements that are marked as transformed (useful in debugging).

SageInterface::collectVarRefs

Collect all variable references in a subtree

SageInterface::collectVariableReferenceUses

Collect variable references together with their exact source use sites.

SageInterface::collectVariableReferencesInArrayTypes

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];

SageInterface::computeUniqueNameForUseAsIdentifier

Traversal to set the global map of names to node and node to names.collisions to support generateUniqueNameForUseAsIdentifier() function.

SageInterface::constantFolding

Constant folding an AST subtree rooted at 'r' (replacing its children with their constant values, if applicable). Please be advised that constant folding on floating point computation may decrease the accuracy of floating point computations! It is a wrapper function for ConstantFolding::constantFoldingOptimization(). Note that only r's children are replaced with their corresponding constant values, not the input SgNode r itself. You have to call this upon an expression's parent node if you want to fold the expression.

SageInterface::convertRefToInitializedName

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.

SageInterface::cutPreprocessingInfo

Cut preprocessing information from a source node and save it into a buffer. Used in combination of pastePreprocessingInfo(). The cut‐paste operation is equivalent to a split movePreprocessingInfo() operation and permits the destination node to be unknown during the cut operation.

SageInterface::deepCopyNode

Deep copy an arbitrary subtree

SageInterface::deepCopyNodeWithIdentityMap

Deep copy an arbitrary subtree and return the copy transaction's exact original‐to‐copy identity map. Consumers must use this map instead of reconstructing correspondence from traversal order or spelling.

SageInterface::deepCopySemanticSubtree

Deep copy a frontend‐owned semantic subtree while preserving its exact source‐provenance classification. This is distinct from deepCopyNode(), which creates a new transformation output surface.

SageInterface::deepDelete

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()

SageInterface::dumpInfo

Dump information about a SgNode for debugging

SageInterface::dumpPreprocInfo

Dumps a located node's preprocessing information.

SageInterface::ensureLocatedNodeFileInfoForTransformation

Ensure a located node has the file‐info objects required before marking it as a transformation/output subtree.

SageInterface::findDeclarationStatement

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

SageInterface::findFunctionDeclaration

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>.

SageInterface::findMain

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

SageInterface::findUnusedLabels

Find unused labels which are not targets of any goto statements

SageInterface::generateUniqueName

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

SageInterface::getAssociatedType

Get the enclosing type of this associated node, not used other than in ./src/backend/unparser/nameQualificationSupport.C

SageInterface::getBoolType

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

SageInterface::getEnclosingClassDeclaration

Get the closest class declaration enclosing the specified AST node,

SageInterface::getEnclosingClassDefinition

Get the closest class definition enclosing the specified AST node,

SageInterface::getEnclosingExprListExp

Get the enclosing SgExprListExp (used as part of function argument index evaluation in subexpressions).

SageInterface::getEnclosingFileNode

get the SgFile node from current node

SageInterface::getEnclosingFunctionDeclaration

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

SageInterface::getEnclosingModuleStatement

Get the closest module statement enclosing the specified AST node,

SageInterface::getEnclosingNode

Find a node by type using upward traversal.

SageInterface::getEnclosingProcedure

Find the function definition

SageInterface::getEnclosingScope

Get the enclosing scope from a node n

SageInterface::getEnclosingSourceFile

Find enclosing source file node

SageInterface::getEnclosingStatement

Find the closest enclosing statement, including the given node

SageInterface::getGlobalScope

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

SageInterface::getLoopIndexVariable

Return the loop index variable for a for loop

SageInterface::getProject

SageInterface::getScope

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

SageInterface::getTemplateDeclaration

Get the enclosing TemplateDeclaration statement

SageInterface::get_name

Generate a useful name to describe the SgNode

SageInterface::hasDetachedTransformationSourcePosition

Return whether every owned source position on a located node identifies one exact detached transformation surface awaiting an output owner.

SageInterface::hasExactSemanticFrontendSourcePosition

Return whether one file‐info record is exact semantic‐only frontend provenance owned by semanticNode. A function declaration can additionally retain its typed physical source‐file association, and an exactly auxiliary‐owned declaration or definition can retain its complete frontend source coordinates, without either becoming a source‐emitted declaration.

SageInterface::hasSemanticOnlyFrontendSourcePosition

Return whether every owned source position on a located node identifies one exact compiler‐generated, frontend‐specific semantic‐only surface.

SageInterface::insideHeader

Check if a node is from a header file

SageInterface::insideSystemHeader

Check if a node is from a system header file

SageInterface::isAncestor

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

SageInterface::isAssignmentStatement

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

SageInterface::isCanonicalForLoop

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

SageInterface::isMain

Check if a SgNode is a main() function declaration

SageInterface::isOmpStatement

Check if a node is SgOmp*Statement

SageInterface::isStructDeclaration

Check if a SgNode is a declaration for a structure

SageInterface::isUnionDeclaration

Check if a SgNode is a declaration for a union

SageInterface::normalizeArrowExpWithAddressOfLeftOperand

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.

SageInterface::outputLocalSymbolTables

Output the local symbol tables.

SageInterface::pastePreprocessingInfo

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

SageInterface::printAST

Pretty print AST horizontally, output to std output.

SageInterface::printAST

Pretty print AST horizontally, output to a specified file, a simpiler interface than printAST2TextFile()

SageInterface::printAST2TextFile

Pretty print AST horizontally, output to a specified text file. If printType is set to false, don't print out type info.

SageInterface::printAST2TextFile

Pretty print AST horizontally, output to a specified text file. If printType is set to false, don't print out types info.

SageInterface::promoteSemanticOnlyNodeToGeneratedOutput

Promote one exact semantic‐only frontend node that a transformation has rewritten into an independently emitted lexical node. The caller supplies the attached physical output owner explicitly; semantic descendants are not reclassified implicitly.

SageInterface::publishGeneratedSubtreeOutputOwner

Publish or validate the exact output owner for generated located nodes before a subtree crosses an attached AST mutation boundary. A physical owner publishes its exact file and occurrence. A semantic owner instead publishes detached transformation descendants as semantic‐only frontend structure and validates existing semantic descendants.

SageInterface::querySubTree

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

SageInterface::rebindVariableReferencesAfterMove

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.

SageInterface::recursivePrintCurrentAndParent

Recursively print current and parent nodes. used within gdb to probe the context of a node.

SageInterface::relocateGeneratedSubtreePhysicalOutputOwner

Relocate generated descendants of an already‐published subtree through one explicit physical‐output file‐and‐occurrence transfer. Source‐spelled descendants retain their original physical provenance. Every generated position must identify priorOwner exactly; this API never infers or repairs an owner.

SageInterface::removeAllOriginalExpressionTrees

Delete exactly owned source‐provenance trees before transforming their semantic expression owners.

SageInterface::removeConsecutiveLabels

Remove consecutive labels

SageInterface::removeJumpsToNextStatement

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

SageInterface::removeLabeledGotos

Remove labeled goto statements

SageInterface::removeUnusedLabels

Remove labels which are not targets of any goto statements: its child statement is also removed by default.

SageInterface::replaceFunctionDefinitionsWithDeclarations

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.

SageInterface::replaceWithPattern

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.

SageInterface::requireTargetSizeType

Return the exact target ABI type used by sizeof/alignof for the context's one owning translation unit. Detached or untyped contexts are malformed.

SageInterface::saveToPDF

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.

SageInterface::serialize

we have two serialize() functions, one for a single node, the other for a list of pointers

SageInterface::setLoopLowerBound

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

SageInterface::setLoopStride

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

SageInterface::setLoopUpperBound

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

SageInterface::setOneSourcePositionForTransformation

Set current node's source position as transformation generated

SageInterface::setOneSourcePositionNull

Set current node's source position as NULL

SageInterface::setSemanticOnlyFrontendSourcePosition

Classify one freshly constructed, non‐expression frontend node as semantic name/structure infrastructure. Any existing or partial source position is a producer error.

SageInterface::setSourcePosition

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

SageInterface::setSourcePositionAsTransformation

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

SageInterface::setSourcePositionAtRootAndAllChildren

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

SageInterface::setSourcePositionForTransformation

Recursively set source position info(Sg_File_Info) as transformation generated

SageInterface::validateSymbolOwnership

Validate that every symbol has one exact owning symbol‐table entry.

SageInterface::whereAmI

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

SgNodeHelper::abbreviatedLocationToString

returns location (consisting of filename, line, column) Abbreviates fileName if too long, max file name length can be set

SgNodeHelper::correspondingSgFunctionDefinition

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).

SgNodeHelper::determineChildIndex

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.

SgNodeHelper::determineVariablesInSubtree

determines all VarRefExp in the subtree of 'node'. The order in the vector corresponds to the traversal order on the AST.

SgNodeHelper::findFunctionDeclarationWithFunctionSymbol

returns the function declaration statement found for a given function symbol.

SgNodeHelper::findVariableDeclarationWithVariableSymbol

returns the declaration statement found for a given variable symbol.

SgNodeHelper::getClosestParentFunctionDefinitionOfLocatedNode

schroder3 (2016‐07‐22): Returns the closest function definition that contains the given node

SgNodeHelper::getCond

returns the root node representing the AST of the condition of If, While, DoWhile, For, CondOperator, switch.

SgNodeHelper::getExprRootChild

returns the child of SgExpressionRoot (which is guaranteed to be unique and to exist)

SgNodeHelper::getExprStmtChild

returns the child of SgExprStatement (which is guaranteed to be unique and to exist)

SgNodeHelper::getFalseBranch

returns the root node representing the AST of the false branch of If, CondOperator.

SgNodeHelper::getFirstChild

returns the first child of an arbitrary AST node (throws exception if numChildren==0)

SgNodeHelper::getFirstOfBlock

returns the first Statement of SgBasicBlock (throws exception if numChildren==0)

SgNodeHelper::getForIncExpr

returns the incr/derc‐expr of For.

SgNodeHelper::getForInitList

returns the initializer‐list of For.

SgNodeHelper::getFunctionCallActualParameterList

return a function‐call's argument list

SgNodeHelper::getFunctionDefinitionFormalParameterList

return a function‐definition's list of formal paramters

SgNodeHelper::getFunctionName

returns function name of SgFunctionDefinition, SgFunctionDeclaration, SgFunctionCall.

SgNodeHelper::getFunctionReturnType

return a function‐definition's return type

SgNodeHelper::getLabelName

returns the label name of a SgLabelStatement without trailing ":"

SgNodeHelper::getLastOfBlock

returns the last Statement of SgBasicBlock (throws exception if numChildren==0)

SgNodeHelper::getLhs

return lhs of a binary node (if it is not a binary node it throws an exception)

SgNodeHelper::getLoopBody

returns the root node representing the AST of the loop body of While, DoWhile, For.

SgNodeHelper::getParent

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.

SgNodeHelper::getRhs

return rhs of a binary node (if it is not a binary node it throws an exception)

SgNodeHelper::getTrueBranch

returns the root node representing the AST of the true branch of If, CondOperator.

SgNodeHelper::getUnaryOpChild

returns the child of a SgUnaryExp (which is guaranteed to be unique and to exist)

SgNodeHelper::isArrayElementAssignment

checks whether the expression 'node' represents an assignment to an array's element considers all assignment operators and arrays of any size

SgNodeHelper::isAstRoot

checks whether the node 'node' is the root node of the AST by using the get_parent function.

SgNodeHelper::isCond

is true if 'node' is the root node of the AST representing the condition of If, While, DoWhile, For, switch, CondExp.

SgNodeHelper::isCondInBranchStmt

is true if 'node' is the root node of the AST representing the condition of If, While, DoWhile, For, switch.

SgNodeHelper::isCondStmt

is true if 'node' is the root node of the AST representing If, While, DoWhile, For, switch.

SgNodeHelper::isCondStmtOrExpr

is true if 'node' is the root node of the AST representing If, While, DoWhile, For, switch, CondExp.

SgNodeHelper::isForIncExpr

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.

SgNodeHelper::isForwardFunctionDeclaration

Determines whether a provided function declaration is a forward declaration

SgNodeHelper::isFunctionParameterVariableSymbol

checks whether a SgVariableSymbol is representing a function parameter (this does not apply for forward declarations)

SgNodeHelper::isLastChildOf

checks whether 'elem' is the last child (in traversal order) of node 'parent'.

SgNodeHelper::isLoopCond

is true if 'node' is the root node of the AST representing the condition of a Loop construct (While, DoWhile, For).

SgNodeHelper::isLoopStmt

is true if 'node' is the root node of the AST representing a Loop construct (While, DoWhile, For).

SgNodeHelper::isPostfixIncDecOp

returns true for Expr‐‐ and Expr‐‐, otherwise false;

SgNodeHelper::isPrefixIncDecOp

returns true for ‐‐Expr and ++Expr, otherwise false.

SgNodeHelper::isVariableSymbolInFunctionForwardDeclaration

checks whether a SgVariableSymbol is representing a variable in

SgNodeHelper::lineColumnAndSourceCodeToString

returns line, column, and unparsed node in one string.

SgNodeHelper::lineColumnPair

returns a std::pair of line and column number. If no file info exists at this node it returns (‐1,‐1).

SgNodeHelper::locationAndSourceCodeToString

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)

SgNodeHelper::locationToString

returns location (consisting of filename, line, column)

SgNodeHelper::loopRelevantBreakStmtNodes

returns a set of SgNode where each node is a break node, but properly excludes all nested loops.

SgNodeHelper::matchExtendedNormalizedCall

matches C and C++ function calls (also ctor and dtor)

SgNodeHelper::nodeToString

returns a string representing the node (excluding the subtree)

SgNodeHelper::numChildren

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.

SgNodeHelper::scopeNestingLevel

computes for a given node at which scope nesting level this node is in its AST

SgNodeHelper::scopeSequenceNumber

computes for a given node at which scope nesting level this node is in its AST

SgNodeHelper::sourceFilenameLineColumnToString

returns filename+line+column information of AST fragment in format "filename:line:column". Used for generating readable output

SgNodeHelper::sourceFilenameToString

returns filename as stored in AST node. Used for generating readable output.

SgNodeHelper::sourceLineColumnToString

returns filename followed by line:column in one string. Used for generating readable output.

SgNodeHelper::sourceLineColumnToString

returns filename followed by line, separator, and column in one string. Used for generating readable output.

SgNodeHelper::switchRelevantCaseStmtNodes

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.

SgNodeHelper::switchRelevantDefaultStmtNode

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.

SgNodeHelper::uniqueLongVariableName

Creates a long unique variable name for a given node of type SgVariableDeclaration or SgVarRefExp

SgNodeHelper::unparseCond

returns the string representing the condition (removes trailing ';')

TransformationTracking::registerAstSubtreeIds

Assign Ids and save current File Info.

VirtualCFG::cfgBeginningOfConstruct

The first CFG node for a construct (before the construct starts to execute)

VirtualCFG::cfgEndOfConstruct

The last CFG node for a construct (after the entire construct has finished executing). This node may not actually be reached if, for example, a goto causes a loop to be exited in the middle

VirtualCFG::cfgIndexForEndWrapper

VirtualCFG::cfgToDot

Dump the filtered dot graph of a virtual control flow graph starting from SgNode (start)

VirtualCFG::cfgToDotForDebugging

Dump the full dot graph of a virtual control flow graph starting from SgNode (start)

VirtualCFG::interestingCfgToDot

Dump a CFG with only interesting nodes for a SgNode

VirtualCFG::makeCfg

Returns CFG node for just before start

VirtualCFG::prependToScopeStmt

* CALL‐BACK FUNCTIONS FOR cfgRWTransaction::transform() **

cfgUtils::isAssignment

/ SgExpression that is that/ assignment (effectively a type cast) or NULL otherwise

sg::ancestor

finds an ancestor node with a given type

sg::assert_sage_type

asserts that n has type SageNode

sg::assume_sage_type

unchecked down cast from SgNode to SageNode

sg::assume_sage_type

SgNodeHelper::Pattern::matchAssertExpr

tests pattern for an assert

SgNodeHelper::Pattern::matchExprStmtAssignOpVarRefExpFunctionCallExp

tests pattern SgExprStatement(SgAssignOp(VarRefExp,FunctionCallExp)) and returns pointer to FunctionCallExp otherwise 0.

SgNodeHelper::Pattern::matchExprStmtFunctionCallExp

tests pattern SgExprStatement(FunctionCallExp) and returns pointer to FunctionCallExp, otherwise 0.

SgNodeHelper::Pattern::matchFunctionCall

tests several patterns and returns pointer to FunctionCallExp inside that matched pattern, otherwise 0.

SgNodeHelper::Pattern::matchFunctionCallExpInVariableDeclaration

tests pattern for function call in variable declaration and returns pointer to FunctionCallExp otherwise 0.

SgNodeHelper::Pattern::matchReturnStmtFunctionCallExp

tests pattern SgReturnStmt(FunctionCallExp) and returns pointer to FunctionCallExp, otherwise 0.

SgNodeHelper::Pattern::matchSingleVarFPrintf

tests pattern SgFunctionCall(...) where the name of the function is fprintf with 3 params

SgNodeHelper::Pattern::matchSingleVarPrintf

tests pattern SgFunctionCall(...) where the name of the function is printf with 2 params

SgNodeHelper::Pattern::matchSingleVarScanf

tests pattern SgFunctionCall(...) where the name of the function is scanf with 2 params

SgNodeHelper::Pattern::matchVariableDeclarationWithFunctionCall

checks variable declaration with function call, returns variable declaration. Otherwise 0. e.g. int x=f();

SgNodeHelper::Pattern::matchVariableDeclarationWithFunctionCall2

checks variable declaration with function call, returns both in a pair, or a with (0,0).

legacy::PRE::getFunctionDefinition

Get the function definition containing a given node

legacy::PRE::partialRedundancyElimination

Do partial redundancy elimination on all functions within the scope n.

Derived Classes

Name

Description

SgExpression

This class represents the notion of an expression. Expressions

SgStatement

This class represents the notion of a statement.

Description

has a position within the source code. There are no uses of this IR node anywhere. All expressions and statements are derived from this IR node to build either SgExpression or SgStatement derived classes. ‐ Note: SgLocatedNode objects have a set_startOfConstruct() and a set_endOfConstruct() these must be set explicitly to define a proper AST. The set_startOfConstruct() will be called if the constructor taking a Sg_File_Info object is called (depreicated) but the set_endOfConstruct() should be called explicitly. ‐ Internal: The AttachedPreprocessingInfoType *p_attachedPreprocessingInfoPtr and the AstAttributeMechanism *p_attribute are implemented as pointers because they would take up 12 bytes each as STL lists and that would be wasteful when we have 20 million IR nodes held in memory. This is a violation of general rule in the IR design that we have STL containers as data member instead of pointers to data members (the file I/O handles this as a special case). ‐ Todo: The AstAttributeMechanism type should be handed as other IR nodes with it's own memory pool, except that in all cases where it would be used, it would be a base class to a user‐defined derived type and thus would not fix in our memory pool. ‐ Todo: Consider name change of "SgLocatedNode" to "SgSourceNode". ‐ Todo: Consider moving some of the IR nodes currently in SgSupport to this IR node. IR nodes that might be moved would include: ‐# SgFile ‐# SgDirectory (questionable) ‐# SgInitializedName ‐# SgBaseClass ‐# SgTemplateArgument ‐# SgTemplateParameter ‐ Internal: This is a base class for all expressions and statements. ‐ See also: Example of using a SgLocatedNode object

Data members

#### SgLocatedNode::p_startOfConstruct This pointer is always valid and stores the source position of the start of the current construct.

#### SgLocatedNode::p_endOfConstruct This pointer is always valid and stores the source position of the end of the current construct.

#### SgLocatedNode::p_attachedPreprocessingInfoPtr Holds comments and/or preprocessor directives located before or after the current statement of expression.

Member functions

#### SgLocatedNode::SgLocatedNode (const SgLocatedNode &X) Copy constructor (made private to prevent being called by accident).

#### SgLocatedNode::SgLocatedNode ( Sg_File_Info* startOfConstruct = NULL ) This is the constructor. This constructor builds the SgLocatedNode base class. ‐ Param startOfConstruct: represents the position in the source code ‐ See also: Example:create an SgLocatedNode object

#### SgLocatedNode::~SgLocatedNode() This is the destructor. Only the Sg_File_Info object can be deleted in this object.

#### SgLocatedNode::getFileName() Access function for "get_file_info()‐>get_filename()". This function is just a simpler access function which retrives the filename from the Sg_File_Info object at the current IR node. This is only a convience function an as a result not a great idea. ‐ Internal: This function should likely be removed from the SAGEIII interface. ‐ Deprecated: This function should be removed because it is only an interface function of rather minor significance. Alternatively if we want to implement it, we should consider placing it at the SgNode object. If we do preserve the function then we should have it return a string instead of char*.

#### SgLocatedNode::addToAttachedPreprocessingInfo (PreprocessingInfo *prepInfoPtr, PreprocessingInfo::RelativePositionType locationInList=PreprocessingInfo::after) This function adds comment or CPP directives to the current IR node. ‐ Param prepInfoPtr: ‐ This parameter is a pointer to the container for the comment/directive. It is used to specify if the new new comment/directive is added to the front or back of the current list of comments/directives. It does not change relative position field of the PreprocessingInfo object. ‐ Param locationInList: ‐ adds container before or after the current IR node. ‐ Return: Returns void.

#### SgLocatedNode::getAttachedPreprocessingInfo (void) This function gets the adds comment or CPP directives to the current IR node. ‐ Param prepInfoPtr: ‐ This parameter is a pointer to the container for the comment/directive. ‐ Param locationInList: ‐ adds container before or after the current IR node. ‐ Return: Returns void.

#### SgLocatedNode::set_startOfConstruct (Sg_File_Info *startOfConstruct) This function sets the current source location position of the start of the current construct. ‐ Param startOfConstruct: ‐ Pointer to Sg_File_Info object containing source location information. ‐ Return: Returns void.

#### SgLocatedNode::set_endOfConstruct (Sg_File_Info *endOfConstruct) This function sets the current source location position of the end of the current construct. ‐ Param endOfConstruct: ‐ Pointer to Sg_File_Info object containing source location information. ‐ Return: Returns void.

#### SgLocatedNode::isSgLocatedNode (SgNode *s) Cast function (from derived class to SgLocatedNode pointer). This functions returns a SgLocatedNode pointer for any input of a pointer to an object derived from a SgLocatedNode. ‐ Return: Returns valid pointer to SgLocatedNode if input is derived from a SgLocatedNode.

#### SgLocatedNode::isSgLocatedNode (const SgNode *s) Cast function (from derived class to SgLocatedNode pointer). This functions returns a SgLocatedNode pointer for any input of a pointer to an object derived from a SgLocatedNode. ‐ Return: Returns valid pointer to SgLocatedNode if input is derived from a SgLocatedNode.

Created with MrDocs