Skip to content

SageInterface

Functions that are useful when operating on the AST.

Namespaces

Name

Detail

Types

Name

Description

CheckedCanonicalLoopPlan

Immutable, fully checked description of one transformable C/C++ loop.

CheckedCanonicalLoopStride

Exact positive stride captured by a checked canonical‐loop plan.

CheckedLoopTilingPlan

CheckedLoopUnrollPlan

DeclarationSets

DeferredTransformation

Add, remove,and replace AST

OutputLocalSymbolTables

PreprocessingInfoData

StatementGenerator

Interface for creating a statement whose computation writes its answer into a given variable.

Transformation_Record

UniqueNameAttribute

A persistent attribute to represent a unique name for an expression

VariableReferenceUse

One variable‐reference spelling and the exact statement that emits it.

const_int_expr_t

The datastructure is used as the return type for SageInterface::evaluateConstIntegerExpression(). One needs to always check whether hasValue_ is true before accessing value_

Enums

Name

Description

CanonicalFortranLoopDirection

DeleteAstMode

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

Functions

Name

Description

HasNoThrowAssign
bool HasNoThrowAssign(SgType const const* inputType);

HasNoThrowConstructor
bool HasNoThrowConstructor(SgType const const* inputType);

HasNoThrowCopy
bool HasNoThrowCopy(SgType const const* inputType);

HasTrivialAssign
bool HasTrivialAssign(SgType const const* inputType);

HasTrivialConstructor
bool HasTrivialConstructor(SgType const const* inputType);

HasTrivialCopy
bool HasTrivialCopy(SgType const const* inputType);

HasTrivialDestructor
bool HasTrivialDestructor(SgType const const* inputType);

HasVirtualDestructor
bool HasVirtualDestructor(SgType const const* inputType);

IsAbstract
bool IsAbstract(SgType const const* inputType);

IsBaseOf
bool IsBaseOf(SgType const const* inputBaseType, SgType const const* inputDerivedType);

IsClass
bool IsClass(SgType const const* inputType);

strip off typedef and modifer types, then check if a type is a class type, excluding union type.

IsEmpty
bool IsEmpty(SgType const const* inputType);

IsEnum
bool IsEnum(SgType const const* inputType);

IsLiteralType
bool IsLiteralType(SgType const const* inputType);

IsPod
bool IsPod(SgType const const* inputType);

IsPolymorphic
bool IsPolymorphic(SgType const const* inputType);

IsStandardLayout
bool IsStandardLayout(SgType const const* inputType);

IsTrivial
bool IsTrivial(SgType const const* inputType);

IsUnion
bool IsUnion(SgType const const* inputType);

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

UnderlyingType
SgType* UnderlyingType(SgType* type);

addDefaultConstructorIfRequired
bool addDefaultConstructorIfRequired(SgClassType* classType, int physical_file_id = Sg_File_Info::TRANSFORMATION_FILE_ID);

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

addMessageStatement
void addMessageStatement(SgStatement* stmt, std::string message);

Function to add "C" style comment to statement.

addStepToLoopBody
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

addVarRefExpFromArrayDimInfo
void addVarRefExpFromArrayDimInfo(SgNode* astNode, std::vector<SgNode*>& NodeList_t);

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

annotateExpressionsWithUniqueNames
void annotateExpressionsWithUniqueNames(SgProject* project);

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

appendArg
SgVariableSymbol* appendArg(SgFunctionParameterList*, SgInitializedName*);

Append an argument to SgFunctionParameterList, transparently set parent,scope, and symbols for arguments when possible We recommend to build SgFunctionParameterList before building a function declaration However, it is still allowed to append new arguments for existing function declarations.

appendExpression
void appendExpression(SgExprListExp*, SgExpression*);

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

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

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

appendStatement
void appendStatement(SgStatement* stmt, SgForInitStatement* for_init_stmt);

appendStatement overloads

appendStatementList
void appendStatementList(std::vector<SgStatement*> const& stmt, SgScopeStatement* scope);

Append a list of statements to the end of an explicit lexical scope.

appendStatementWithDependentDeclaration
void appendStatementWithDependentDeclaration(SgDeclarationStatement* decl, SgGlobal* scope, SgStatement* original_statement, SgFunctionDeclaration* source_call_declaration, bool excludeHeaderFiles, std::vector<PreprocessingInfo> const& original_directives, SgSourceFile* original_source_file = NULL, int original_physical_file_id = ‐1);

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

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

Compute the intersection set for two ASTs.

attachComment
PreprocessingInfo* attachComment(SgLocatedNode* target, std::string const& content, PreprocessingInfo::DirectiveType commentStyle, PreprocessingInfo::RelativePositionType position = PreprocessingInfo::before);

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

beginDetachedForStatementConstruction
void beginDetachedForStatementConstruction(SgForStatement* statement, SgScopeStatement* exactOutputOwner);

beginDetachedFunctionParameterScopeConstruction
void beginDetachedFunctionParameterScopeConstruction(SgFunctionParameterScope* parameterScope, SgScopeStatement* exactPhysicalOutputOwner, SgScopeStatement* exactSemanticScope);

Begin the one exact bottom‐up construction transaction for a detached function‐parameter scope. The scope is semantic name infrastructure and must already carry exact semantic‐only provenance. The physical output owner and semantic lookup scope are independent, explicit roles; this is required for a parameter scope nested in another detached declarative region. No parent‐chain inference is performed.

buildDeclarationSets
DeclarationSets* buildDeclarationSets(SgNode*);

buildForwardFunctionDeclaration
SgTemplateInstantiationMemberFunctionDecl* buildForwardFunctionDeclaration(SgTemplateInstantiationMemberFunctionDecl* memberFunctionInstantiation);

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

buildFunctionPrototype
SgFunctionDeclaration* buildFunctionPrototype(SgFunctionDeclaration* functionDeclaration);

Build a nondefining declaration from an exact function definition whose structural and semantic scopes permit a prototype at the same source location. In particular, out‐of‐class member definitions are rejected: their existing in‐class declaration is the only legal prototype. Malformed or unsupported inputs are hard errors; this function never returns null.

call_liveness_analysis
LivenessAnalysis* call_liveness_analysis(SgProject* project, bool debug = false);

Call liveness analysis on an entire project

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

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

changeContinuesToGotos
void changeContinuesToGotos(SgStatement* stmt, SgLabelStatement* label);

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

checkAccessPermissions
void checkAccessPermissions(SgNode*);

checkForInitializers
void checkForInitializers(SgNode* node);

checkSgNodePointers
void checkSgNodePointers();

checkSymbolTables
void checkSymbolTables(SgNode*);

checkTypesAreEqual
bool checkTypesAreEqual(SgType* typeA, SgType* typeB);

cleanupNontransformedBasicBlockNode
void cleanupNontransformedBasicBlockNode();

Remove unused basic block IR nodes added as part of normalization.

clearMangledNameCache
void clearMangledNameCache(SgGlobal* globalScope);

clearScopeNumbers
void clearScopeNumbers(SgFunctionDefinition* functionDefinition);

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

clearSharedGlobalScopes
void clearSharedGlobalScopes(SgProject* project);

cloneDetachedGeneratedTemplateParameter
SgTemplateParameter* cloneDetachedGeneratedTemplateParameter(SgTemplateParameter const* source, char const* context);

Clone one template parameter for a generated declaration. Template‐template declaration identities are copied independently, and every generated located descendant is left detached until the destination declaration publishes its exact physical output owner.

collectCppDirectiveSnapshot
std::vector<PreprocessingInfo> collectCppDirectiveSnapshot(SgSourceFile* file);

Capture the primary source file's preprocessing directives in physical source order. The returned values are independent of later AST mutations.

collectDirectIncludeSystemRoles
std::map<std::string, bool> collectDirectIncludeSystemRoles(SgSourceFile* file);

Return the exact system/application role of every direct textual include in a source file, keyed by its source spelling. A lazily absent graph root is accepted only when the exact primary preprocessing stream proves that the source has no includes. Conflicting or incomplete include‐graph ownership is a frontend invariant violation.

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

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

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

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

collectReadWriteRefs
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++

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

collectSourceSequenceNumbers
std::set<unsigned int> collectSourceSequenceNumbers(SgNode* astNode);

collectTransformedStatements
std::set<SgStatement*> collectTransformedStatements(SgNode* node);

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

collectUseByAddressVariableRefs
void collectUseByAddressVariableRefs(SgStatement const* 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++

collectVarRefs
void collectVarRefs(SgLocatedNode* root, std::vector<SgVarRefExp*>& result);

Collect all variable references in a subtree

collectVariableReferenceUses
void collectVariableReferenceUses(SgLocatedNode* root, std::vector<VariableReferenceUse>& result);

Collect variable references together with their exact source use sites.

collectVariableReferencesInArrayTypes
int collectVariableReferencesInArrayTypes(SgLocatedNode* root, std::vector<SgNode*>& currentVarRefList);

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

commitLoopTiling
void commitLoopTiling(CheckedLoopTilingPlan const& plan);

commitLoopUnrolling
void commitLoopUnrolling(CheckedLoopUnrollPlan const& plan);

completeDetachedForStatementConstruction
void completeDetachedForStatementConstruction(SgForStatement* statement);

completeDetachedFunctionParameterScopeConstruction
void completeDetachedFunctionParameterScopeConstruction(SgFunctionDeclaration* declaration, SgFunctionParameterScope* parameterScope);

Attach a parameter scope to its final declaration and consume its exact detached construction transaction. The scope remains semantic‐only while physically emitted descendants retain the transaction's explicit output owner. Missing, stale, or mismatched transactions are hard errors.

completeDetachedRequiresParameterScopeConstruction
void completeDetachedRequiresParameterScopeConstruction(SgRequiresExpr* requiresExpression, SgFunctionParameterScope* parameterScope);

Attach a detached local‐parameter scope to the requires‐expression that owns its declarative region and consume the same exact construction transaction used while translating the local parameters.

computeUniqueNameForUseAsIdentifier
void computeUniqueNameForUseAsIdentifier(SgNode* astNode);

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

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

containsUnknownType
bool containsUnknownType(SgType* type);

Check if a type (or any nested type) is unknown/incomplete.

convertAllForsToWhiles
void convertAllForsToWhiles(SgNode* top);

convertForToWhile
void convertForToWhile(SgForStatement* f);

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

copyExpression
SgExpression* copyExpression(SgExpression* e);

Deep copy an expression

copyStatement
SgStatement* copyStatement(SgStatement* s);

Deep copy a statement

createTempVariableAndReferenceForExpression
std::pair<SgVariableDeclaration*, SgExpression*> createTempVariableAndReferenceForExpression(SgExpression* expression, SgScopeStatement* scope);

createTempVariableForExpression
std::pair<SgVariableDeclaration*, SgExpression*> createTempVariableForExpression(SgExpression* expression, SgStatement* insertionAnchor, bool initializeInDeclaration, SgAssignOp** reEvaluate = NULL);

Given an expression and an exact attached insertion anchor, atomically inserts a temporary variable immediately before the anchor and publishes its symbol. The returned variable‐reference expression can be used instead of the original expression. The optional SgAssignOp reevaluates the expression. Reference types are represented by pointer temporaries.

cutPreprocessingInfo
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 equivalent to a split movePreprocessingInfo() operation and permits the destination node to be unknown during the cut operation.

cxxNonTypeTemplateArgumentTypeConversionIsExact
bool cxxNonTypeTemplateArgumentTypeConversionIsExact(SgType const* source, SgType const* parameter);

Verify that the exact type of a written C++ non‐type template argument can undergo the standard conversion represented by its canonical parameter type. This is deliberately narrower than general implicit conversion: it covers top‐level cv removal, qualification adjustment, array/function decay, reference binding, and null pointer conversion without treating unrelated but similarly spelled types as equivalent.

cxxSourceTemplateArgumentPrefixMatchesSemantic
bool cxxSourceTemplateArgumentPrefixMatchesSemantic(SgTemplateArgumentPtrList const& source, SgTemplateArgumentPtrList const& semantic);

Verify that a list of written C++ template arguments is the exact explicit prefix of a resolved semantic argument list. The semantic list may contain a defaulted suffix and may canonicalize source type spelling.

cxxSourceTypeMatchesSemanticType
bool cxxSourceTypeMatchesSemanticType(SgType const* source, SgType const* semantic);

Verify that a distinct C++ TypeLoc‐owned source type resolves to its exact canonical semantic type. This includes written template‐id graphs whose SgNonrealType identity is intentionally distinct from the resolved class or alias‐template instantiation.

declarationPositionString
std::string declarationPositionString(SgDeclarationStatement const* declaration);

Generate a unique string from the source file position information

declarationPreceedsDefinition
bool declarationPreceedsDefinition(SgDeclarationStatement* nonDefiningDeclaration, SgDeclarationStatement* definingDeclaration);

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

deepCopy
template<typename NodeType> NodeType* deepCopy(NodeType const* 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);

deepCopyNode
SgNode* deepCopyNode(SgNode const* subtree);

Deep copy an arbitrary subtree

deepCopyNodeWithIdentityMap
SgNode* deepCopyNodeWithIdentityMap(SgNode const* subtree, SgCopyHelp::copiedNodeMapType& identityMap);

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.

deepCopySemantic
template<typename NodeType> NodeType* deepCopySemantic(NodeType const* subtree);

Typed frontend‐semantic counterpart to deepCopy().

deepCopySemanticSubtree
SgNode* deepCopySemanticSubtree(SgNode const* subtree);

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.

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

deleteAST
void deleteAST(SgNode* node);

detachAllSymbolsFromScope
void detachAllSymbolsFromScope(SgScopeStatement* scope);

Detach every symbol through the symbol table's exact ownership API.

detectCycleInType
void detectCycleInType(SgType* type, std::string const& from);

displayScope
void displayScope(SgScopeStatement* scope);

doLoopNormalization
void doLoopNormalization(SgFortranDo* loop);

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

dumpInfo
void dumpInfo(SgNode* node, std::string desc = "");

Dump information about a SgNode for debugging

dumpPreprocInfo
void dumpPreprocInfo(SgLocatedNode* locatedNode);

Dumps a located node's preprocessing information.

enclosingNamespaceScope
SgNamespaceDefinitionStatement* enclosingNamespaceScope(SgDeclarationStatement* declaration);

Find the enclosing namespace of a declaration

ensureBasicBlockAsBodyOfCaseOption
SgBasicBlock* ensureBasicBlockAsBodyOfCaseOption(SgCaseOptionStmt* cs);

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

ensureBasicBlockAsBodyOfCatch
SgBasicBlock* ensureBasicBlockAsBodyOfCatch(SgCatchOptionStmt* cos);

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

ensureBasicBlockAsBodyOfDefaultOption
SgBasicBlock* ensureBasicBlockAsBodyOfDefaultOption(SgDefaultOptionStmt* cs);

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

ensureBasicBlockAsBodyOfDoWhile
SgBasicBlock* ensureBasicBlockAsBodyOfDoWhile(SgDoWhileStmt* ws);

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

ensureBasicBlockAsBodyOfFor
SgBasicBlock* ensureBasicBlockAsBodyOfFor(SgForStatement* fs);

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

ensureBasicBlockAsBodyOfOmpBodyStmt
SgBasicBlock* ensureBasicBlockAsBodyOfOmpBodyStmt(SgOmpBodyStatement* ompbodyStmt);

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

ensureBasicBlockAsBodyOfSwitch
SgBasicBlock* ensureBasicBlockAsBodyOfSwitch(SgSwitchStatement* ws);

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

ensureBasicBlockAsBodyOfWhile
SgBasicBlock* ensureBasicBlockAsBodyOfWhile(SgWhileStmt* ws);

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

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

ensureBasicBlockAsTrueBodyOfIf
SgBasicBlock* ensureBasicBlockAsTrueBodyOfIf(SgIfStmt* ifs);

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

ensureCaseInsensitiveSymbolTable
void ensureCaseInsensitiveSymbolTable(SgScopeStatement* scope, bool force_case_insensitive);

ensureLocatedNodeFileInfoForTransformation
void ensureLocatedNodeFileInfoForTransformation(SgLocatedNode* locatedNode);

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

eraseNullPreprocessingInfo
int eraseNullPreprocessingInfo(SgLocatedNode* lnode);

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

exactCanonicalLoopTripCount
std::optional<unsigned long long> exactCanonicalLoopTripCount(CheckedCanonicalLoopPlan const& plan);

Return an exact constant trip count when both bounds are exact integer constants in the induction type's domain and the terminal increment cannot overflow or wrap. Dynamic bounds, an unsafe terminal increment, and an unrepresentable count return nullopt; a consumer requiring a constant count must reject nullopt.

extractPragmaKeyword
std::string extractPragmaKeyword(SgPragmaDeclaration const*);

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

findBreakStmts
std::vector<SgBreakStmt*> findBreakStmts(SgStatement* code, std::string const& 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.

findContinueStmts
std::vector<SgContinueStmt*> findContinueStmts(SgStatement* code, std::string const& 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.

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

findEnclosingLoop
SgScopeStatement* findEnclosingLoop(SgStatement* s, std::string const& 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

findEnclosingOmpClauseBodyStatement
SgOmpClauseBodyStatement* findEnclosingOmpClauseBodyStatement(SgStatement* s);

Find enclosing OpenMP clause body statement from s. If s is already one, return it directly.

findEnclosingSwitch
SgSwitchStatement* findEnclosingSwitch(SgStatement* s);

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

findFirstDefiningFunctionDecl
SgFunctionDeclaration* findFirstDefiningFunctionDecl(SgScopeStatement* scope);

Find the first defining function declaration statement in a scope

findFirstSgCastExpMarkedAsTransformation
bool findFirstSgCastExpMarkedAsTransformation(SgNode* n, std::string const& s);

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

findFunctionType
SgFunctionType* findFunctionType(SgType* return_type, SgFunctionParameterTypeList* typeList);

Find the function type matching a function signature plus a given return type

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

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

findMain
SgFunctionDeclaration* findMain(SgNode* currentNode);

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

findSurroundingStatementFromSameFile
SgStatement* findSurroundingStatementFromSameFile(SgStatement* targetStmt, bool& surroundingStatementPreceedsTargetStatement);

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

findUnusedLabels
std::set<SgLabelStatement*> findUnusedLabels(SgNode* top);

Find unused labels which are not targets of any goto statements

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

fixFunctionDeclaration
void fixFunctionDeclaration(SgFunctionDeclaration* stmt, SgScopeStatement* scope);

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

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

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

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

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

fixTemplateDeclaration
void fixTemplateDeclaration(SgTemplateDeclaration* stmt, SgScopeStatement* scope);

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

fixVariableDeclaration
void fixVariableDeclaration(SgVariableDeclaration* varDecl, SgScopeStatement* scope);

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

fixupReferencesToSymbols
void fixupReferencesToSymbols(SgScopeStatement const* 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.

forLoopNormalization
void forLoopNormalization(SgForStatement* loop, bool foldConstant = true);

Normalize a for loop. Malformed or non‐canonicalizable loop headers are hard errors detected by a read‐only preflight before the AST is mutated.

forallMaskExpression
SgExpression* forallMaskExpression(SgForAllStatement* stmt);

Get the mask expression from the header of a SgForAllStatement

fortranSourceFunctionResultMatchesSemanticResult
bool fortranSourceFunctionResultMatchesSemanticResult(SgFunctionType const* source, SgFunctionType const* semantic);

Verify that a Fortran source‐syntax function result has the same resolved meaning as its canonical semantic result. Explicit KIND/LEN selectors use typed folded metadata; only omitted selectors may match by intrinsic family.

fortranSourceTypeMatchesSemanticExpressionType
bool fortranSourceTypeMatchesSemanticExpressionType(SgType const* source, SgType const* semantic);

Verify that an exact Fortran source type resolves to a semantic expression result type. A nonconstant source CHARACTER LEN selector may match only the explicit dynamic‐result marker used by semantic expression types.

fortranSourceTypeMatchesSemanticType
bool fortranSourceTypeMatchesSemanticType(SgType const* source, SgType const* semantic);

Verify that an exact Fortran source scalar type resolves to the canonical semantic scalar type without discarding explicit KIND/LEN selectors.

functionCallExpressionPreceedsDeclarationWhichAssociatesScope
bool functionCallExpressionPreceedsDeclarationWhichAssociatesScope(SgFunctionCallExp* functionCall);

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

Returns STL vector of SgFile IR node pointers.

generateFunctionDefinitionsList
std::vector<SgFunctionDeclaration*> generateFunctionDefinitionsList(SgNode* node);

generateProjectName
std::string generateProjectName(SgProject const* project, bool supressSuffix = false);

Added mechanism to generate project name from list of file names

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

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

generateUniqueNameForUseAsIdentifier
std::string generateUniqueNameForUseAsIdentifier(SgDeclarationStatement* declaration);

Generate a useful name to support construction of identifiers from declarations.

generateUniqueNameForUseAsIdentifier_support
std::string generateUniqueNameForUseAsIdentifier_support(SgDeclarationStatement* declaration);

generateUniqueVariableName
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. # is a unique integer counter.

getAllStatementsAtLine
void getAllStatementsAtLine(SgSourceFile* sourceFile, int line, SgStatementPtrList& returnList);

Obtain all the queryed statement at line of a source file

getArrayElementCount
size_t getArrayElementCount(SgArrayType* t);

Calculate the number of elements of an array type: dim1* dim2*... , assume element count is 1 for int a[].

getArrayElementType
SgType* getArrayElementType(SgType* t);

Get the element type of an array. It recursively find the base type for multi‐dimension array types

getAssociatedType
SgType* getAssociatedType(SgNode const* astNode);

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

getAssociatedTypeFromFunctionTypeList
SgType* getAssociatedTypeFromFunctionTypeList(SgExpression* actual_argument_expression);

Get the type of the associated argument expression from the function type.

getBoolType
SgType* getBoolType(SgNode* n);

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

getClassTypeChainForMemberReference
std::list<SgClassType*> getClassTypeChainForMemberReference(SgExpression* refExp);

getDeclarationOfNamedFunction
SgFunctionDeclaration* getDeclarationOfNamedFunction(SgExpression* func);

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

getDeclaredType
SgType* getDeclaredType(SgDeclarationStatement const* declaration);

Returns the type introduced by a declaration.

getDefaultConstructor
SgMemberFunctionDeclaration* getDefaultConstructor(SgClassDeclaration* classDeclaration);

Get the default constructor from the class declaration

getDefaultDestructor
SgMemberFunctionDeclaration* getDefaultDestructor(SgClassDeclaration* classDeclaration);

Get the default destructor from the class declaration

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

getDimensionCount
int getDimensionCount(SgType* t);

Get the number of dimensions of an array type

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

getEnclosingClassDeclaration
SgClassDeclaration* getEnclosingClassDeclaration(SgNode* astNode);

Get the closest class declaration enclosing the specified AST node,

getEnclosingClassDefinition
SgClassDefinition* getEnclosingClassDefinition(SgNode* astnode, bool const includingSelf = false);

Get the closest class definition enclosing the specified AST node,

getEnclosingExprListExp
SgExprListExp* getEnclosingExprListExp(SgNode* astNode, bool const includingSelf = false);

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

getEnclosingFileNode
SgFile* getEnclosingFileNode(SgNode* astNode);

get the SgFile node from current node

getEnclosingFunctionDeclaration
SgFunctionDeclaration* getEnclosingFunctionDeclaration(SgNode* astNode, bool const includingSelf = false);

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

getEnclosingFunctionDefinition
SgFunctionDefinition* getEnclosingFunctionDefinition(SgNode* astNode, bool const includingSelf = false);

getEnclosingModuleStatement
SgModuleStatement* getEnclosingModuleStatement(SgNode* astNode, bool const includingSelf = false);

Get the closest module statement enclosing the specified AST node,

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

Find a node by type using upward traversal.

getEnclosingProcedure
SgFunctionDefinition* getEnclosingProcedure(SgNode* n, bool const includingSelf = false);

Find the function definition

getEnclosingScope
SgScopeStatement* getEnclosingScope(SgNode* n, bool const includingSelf = false);

Get the enclosing scope from a node n

getEnclosingSourceFile
SgSourceFile* getEnclosingSourceFile(SgNode const* n, bool const includingSelf = false);

Find enclosing source file node

getEnclosingStatement
SgStatement* getEnclosingStatement(SgNode* n);

Find the closest enclosing statement, including the given node

getFirstGlobalScope
SgGlobal* getFirstGlobalScope(SgProject* project);

return the first global scope under current project

getFirstInitializedName
SgInitializedName* getFirstInitializedName(SgVariableDeclaration* decl);

Get the first initialized name of a declaration statement

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

getFirstStatementAtLine
SgStatement* getFirstStatementAtLine(SgSourceFile* sourceFile, int line);

Obtain the first queryed statement at line of a source file

getFirstVarSym
SgVariableSymbol* getFirstVarSym(SgVariableDeclaration* decl);

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

getFirstVarType
SgType* getFirstVarType(SgVariableDeclaration* decl);

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

getFirstVariable
SgInitializedName& getFirstVariable(SgVariableDeclaration& vardecl);

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

getForLoopInformations
bool getForLoopInformations(SgForStatement* for_loop, SgVariableSymbol*& iterator, SgExpression*& lower_bound, SgExpression*& upper_bound, SgExpression*& stride, bool& has_incremental_iteration_space, bool& has_inclusive_bound);

getFortranProgramUnitSymbolTableKey
SgName getFortranProgramUnitSymbolTableKey(SgFunctionDeclaration const* decl);

Return the symbol‐table key for a Fortran program unit. Anonymous program units receive a stable, source‐position‐derived internal key while their public SgFunctionDeclaration::get_name() remains empty.

getFrontendSpecificNodes
std::set<SgNode*> getFrontendSpecificNodes();

getFunctionDeclaration
SgFunctionDeclaration* getFunctionDeclaration(SgFunctionCallExp* functionCallExp);

getGlobalScope
SgGlobal* getGlobalScope(SgNode const* astNode);

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

getInParameters
std::vector<SgInitializedName*> getInParameters(SgInitializedNamePtrList const& params);

Get a vector of input parameters from the function parameter list

getInitializerOfExpression
SgInitializer* getInitializerOfExpression(SgExpression* n);

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

getIntegerConstantValue
unsigned long long 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.

getLastStatement
SgStatement* getLastStatement(SgScopeStatement* scope);

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

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

getLoopBody
SgStatement* getLoopBody(SgScopeStatement* loop);

Routines to get and set the body of a loop

getLoopCondition
SgStatement* getLoopCondition(SgScopeStatement* loop);

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

getLoopIndexVariable
SgInitializedName* getLoopIndexVariable(SgNode* loop);

Return the loop index variable for a for loop

getMangledNameFromCache
std::string getMangledNameFromCache(SgNode* astNode);

getNextStatement
SgStatement* getNextStatement(SgStatement* currentStmt);

Get next statement within the same scope of current statement

getNonInstantiatonDeclarationForClass
SgDeclarationStatement* getNonInstantiatonDeclarationForClass(SgTemplateInstantiationMemberFunctionDecl* memberFunctionInstantiation);

getOutParameters
std::vector<SgInitializedName*> getOutParameters(SgInitializedNamePtrList const& params);

Get a vector of output parameters from the function parameter list

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

getProject
SgProject* getProject();

Get the current SgProject IR Node.

getScope
SgScopeStatement* getScope(SgNode const* astNode);

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

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

Query memory pools to grab SgNode of a specified type

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

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

Find referenced symbols within an expression

getTemplateDeclaration
SgDeclarationStatement* getTemplateDeclaration(SgNode const* astNode);

Get the enclosing TemplateDeclaration statement

getTemplateParameterKeyword
SgTemplateParameter::template_parameter_keyword_enum getTemplateParameterKeyword(SgTemplateParameter* param);

getTypeName
std::string getTypeName(SgType* type);

Get the string representing the type name

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

returns the array dimensions in an array as defined for arrtype

get_name
std::string get_name(SgC_PreprocessorDirectiveStatement const* directive);

get_name overloads

hasDetachedTransformationSourcePosition
bool hasDetachedTransformationSourcePosition(SgLocatedNode const* generatedNode);

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

hasExactSemanticAuxiliaryOwnership
bool hasExactSemanticAuxiliaryOwnership(SgDeclarationStatement const* declaration);

Return whether a declaration has exact semantic‐auxiliary ownership. A declaration whose parent is an auxiliary container must satisfy the complete reciprocal scope/container/list contract; malformed partial ownership is a hard error.

hasExactSemanticFrontendSourcePosition
bool hasExactSemanticFrontendSourcePosition(SgNode const* semanticNode, Sg_File_Info const* position);

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.

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

hasSameGlobalScope
bool hasSameGlobalScope(SgStatement* statement_1, SgStatement* statement_2);

This is supporting the recognition of functions in header files from two different ASTs

hasSemanticOnlyFrontendSourcePosition
bool hasSemanticOnlyFrontendSourcePosition(SgLocatedNode const* semanticNode);

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

hasSimpleChildrenList
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 . for example, SgBasicBlock has a simple statement list while IfStmt does not.

hasTemplateSyntax
bool hasTemplateSyntax(SgName const& name);

hasTrivialDestructor
bool hasTrivialDestructor(SgType* t);

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

initializeIfStmt
void initializeIfStmt(SgIfStmt* ifstmt, SgStatement* conditional, SgStatement* true_body, SgStatement* false_body);

Support function used for variable declarations in conditionals

initializeSwitchStatement
void initializeSwitchStatement(SgSwitchStatement* switchStatement, SgStatement* item_selector, SgStatement* body);

Support function used for variable declarations in conditionals

initializeWhileStatement
void initializeWhileStatement(SgWhileStmt* whileStatement, SgStatement* condition, SgStatement* body);

Support function used for variable declarations in conditionals

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

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

insertHeader
PreprocessingInfo* insertHeader(std::string const& filename, PreprocessingInfo::RelativePositionType position, bool isSystemHeader, SgScopeStatement* scope);

insertHeader overloads

insertStatement
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

insertStatementAfter
void insertStatementAfter(SgStatement* targetStmt, SgStatement* newStmt, bool autoMovePreprocessingInfo = true);

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

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

insertStatementAfterLastDeclaration overloads

insertStatementBefore
void insertStatementBefore(SgStatement* targetStmt, SgStatement* newStmt, bool autoMovePreprocessingInfo = true);

Insert a statement before a target statement

insertStatementBeforeFirstNonDeclaration
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

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

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

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

Insert a list of statements after a target statement

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

Insert a list of statements before a target statement

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

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

insideHeader
bool insideHeader(SgLocatedNode* node);

Check if a node is from a header file

insideSystemHeader
bool insideSystemHeader(SgLocatedNode* node);

Check if a node is from a system header file

instrumentEndOfFunction
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. Useful when adding a runtime library call to terminate the runtime system right before the end of a program (e.g., OpenMP). Return with complex expressions with side effects are rewritten using an additional assignment statement.

isAbbreviatedFunctionTemplateParameter
bool isAbbreviatedFunctionTemplateParameter(SgTemplateParameter* param);

isAddressOfCurrentObjectDataMemberReference
bool isAddressOfCurrentObjectDataMemberReference(SgVarRefExp* varRefExp);

isAddressTaken
bool isAddressTaken(SgExpression* refExp);

isAncestor
bool isAncestor(SgNode* node1, SgNode* node2);

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

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

isAssignable
bool isAssignable(SgType* type);

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

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

isAstTeardownEnabled
bool isAstTeardownEnabled();

Returns true if AST teardown is enabled for this process.

isBodyStatement
bool isBodyStatement(SgStatement* s);

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

isCallToParticularFunction
bool isCallToParticularFunction(SgFunctionDeclaration* decl, SgExpression* e);

isCanonicalDoLoop
bool isCanonicalDoLoop(SgFortranDo* loop, SgInitializedName ivar, SgExpression lb, SgExpression ub, SgExpression step, SgStatement** body, CanonicalFortranLoopDirection* direction, bool* isInclusiveUpperBound);

Check if a Fortran Do loop has a complete canonical form: Do I=1, 10, 1. A nonconstant step has runtime direction; it must never be guessed to be increasing by consumers.

isCanonicalForLoop
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

isConstType
bool isConstType(SgType* t);

isConstantFalse
bool isConstantFalse(SgExpression* e);

Check if a bool or int constant expression evaluates to be a false value

isConstantTrue
bool isConstantTrue(SgExpression* e);

Check if a bool or int constant expression evaluates to be a true value

isCopyConstructible
bool isCopyConstructible(SgType* type);

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

isDataMemberReference
bool isDataMemberReference(SgVarRefExp* varRefExp);

isDefaultConstructible
bool isDefaultConstructible(SgType* type);

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

isEqualToIntConst
bool isEqualToIntConst(SgExpression* e, int value);

Compare AST nodes, subtree, etc

isEquivalentFunctionType
bool isEquivalentFunctionType(SgFunctionType const* lhs, SgFunctionType const* 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.

isEquivalentType
bool isEquivalentType(SgType const* lhs, SgType const* rhs);

Test for equivalence of types independent of access permissions (private or protected modes for members of classes).

isExactTagTypeIdentity
bool isExactTagTypeIdentity(SgType* declaratorType, SgDeclarationStatement* sourceOwnedTag);

Returns true when a declarator type names the supplied exact source‐owned class or enum declaration. Externally named tag types are shared across a project, so the type's canonical declaration family may belong to another translation unit while the supplied declaration remains the sole owner of its local source surface.

isExtern
bool isExtern(SgDeclarationStatement* stmt);

Check if a declaration has an "extern" modifier

isFortranProgramUnitWithoutSourceName
bool isFortranProgramUnitWithoutSourceName(SgFunctionDeclaration const* decl);

Return true only for a Fortran main program or BLOCK DATA program unit whose source syntax has no name. The function hard‐fails when the public declaration name and the explicit source‐name metadata disagree.

isInSubTree
bool isInSubTree(SgExpression* subtree, SgExpression* exp);

isIndexOperator
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[]).

isLambdaCapturedVariable
bool isLambdaCapturedVariable(SgVarRefExp* varRef);

check if a variable reference is this‐>a[i]inside of a lambda function

isLambdaFunction
bool isLambdaFunction(SgFunctionDeclaration* func);

Check if a function declaration is a C++11 lambda function

isLastStatement
bool isLastStatement(SgStatement* stmt);

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

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

isMain
bool isMain(SgNode const* node);

Check if a SgNode is a main() function declaration

isMemberFunctionMemberReference
bool isMemberFunctionMemberReference(SgMemberFunctionRefExp* memberFunctionRefExp);

isMutable
bool isMutable(SgInitializedName* name);

True if an SgInitializedName is "mutable' (has storage modifier set)

isNonconstReference
bool isNonconstReference(SgType* t);

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

isOmpStatement
bool isOmpStatement(SgNode*);

Check if a node is SgOmp*Statement

isOverloaded
bool isOverloaded(SgFunctionDeclaration* functionDeclaration);

Return true if function is overloaded.

isOverloadedArrowOperator
bool isOverloadedArrowOperator(SgExpression* expr);

isOverloadedArrowOperator overloads

isOverloadedArrowOperatorChain
bool isOverloadedArrowOperatorChain(SgExpression* expr);

Return true if expr is part of an overloaded operator‐> call chain.

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

isPointerType
bool isPointerType(SgType* t);

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

isPostfixOperator
bool isPostfixOperator(SgExpression* exp);

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

isPrefixOperator
bool isPrefixOperator(SgExpression* exp);

isPrefixOperatorName
bool isPrefixOperatorName(SgName const& functionName);

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

isPrototypeInScope
bool isPrototypeInScope(SgScopeStatement* scope, SgFunctionDeclaration* functionDeclaration, SgDeclarationStatement* startingAtDeclaration);

isPureVirtualClass
bool isPureVirtualClass(SgType* type, ClassHierarchyWrapper const& 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.

isReferenceType
bool isReferenceType(SgType* t);

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

isRemovableStatement
bool isRemovableStatement(SgStatement* s);

isRestrictType
bool isRestrictType(SgType* t);

Is this a restrict type?

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

isScalarType
bool 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

isStatic
bool isStatic(SgDeclarationStatement* stmt);

Check if a declaration has a "static' modifier

isStrictIntegerType
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

isStructDeclaration
bool isStructDeclaration(SgNode* node);

Check if a SgNode is a declaration for a structure

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

isStructurallyEquivalentAST
bool isStructurallyEquivalentAST(SgNode* tree1, SgNode* tree2);

isTemplateInstantiationNode
bool isTemplateInstantiationNode(SgNode* node);

isUnionDeclaration
bool isUnionDeclaration(SgNode* node);

Check if a SgNode is a declaration for a union

isUseByAddressVariableRef
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++

isValidFortranSourceIdentifier
bool isValidFortranSourceIdentifier(std::string const& name);

Return whether a spelling is a valid Fortran source identifier.

isVolatileType
bool isVolatileType(SgType* t);

Is this a volatile type?

is_C99_language
bool is_C99_language();

is_CAF_language
bool is_CAF_language();

is_C_language
bool is_C_language();

is_Cuda_language
bool is_Cuda_language();

is_Cxx_family_language
bool is_Cxx_family_language();

is_Cxx_language
bool is_Cxx_language();

is_Fortran_language
bool is_Fortran_language();

is_OpenCL_language
bool is_OpenCL_language();

is_OpenMP_language
bool is_OpenMP_language();

is_language_case_insensitive
bool is_language_case_insensitive();

is_mixed_C_and_Cxx_language
bool is_mixed_C_and_Cxx_language();

is_mixed_Fortran_and_C_and_Cxx_language
bool is_mixed_Fortran_and_C_and_Cxx_language();

is_mixed_Fortran_and_C_language
bool is_mixed_Fortran_and_C_language();

is_mixed_Fortran_and_Cxx_language
bool is_mixed_Fortran_and_Cxx_language();

language_may_contain_nondeclarations_in_scope
bool language_may_contain_nondeclarations_in_scope();

lastFrontEndSpecificStatement
SgStatement* lastFrontEndSpecificStatement(SgGlobal* globalScope);

lastStatementOfScopeWithTokenInfo
SgStatement* lastStatementOfScopeWithTokenInfo(SgScopeStatement* scope, std::map<SgNode*, TokenStreamSequenceToNodeMapping*>& tokenStreamSequenceMap);

Used to support token unparsing (when the output the trailing token sequence).

listHeaderFiles
void listHeaderFiles(SgIncludeFile* includeFile);

return path prefix for subtree of include files.

lookupClassSymbolInParentScopes
SgClassSymbol* lookupClassSymbolInParentScopes(SgName const& name, SgScopeStatement* currentScope = NULL, SgTemplateArgumentPtrList* templateArgumentList = NULL);

lookupEnumSymbolInParentScopes
SgEnumSymbol* lookupEnumSymbolInParentScopes(SgName const& name, SgScopeStatement* currentScope = NULL);

lookupFortranCommonBlockObject
SgCommonBlockObject* lookupFortranCommonBlockObject(SgName const& useName, SgNode const* context);

Resolve a Fortran common‐block designator in its lexical program‐unit scope. Missing and ambiguous declarations are hard errors.

lookupFunctionSymbolInParentScopes
SgFunctionSymbol* lookupFunctionSymbolInParentScopes(SgName const& functionName, SgScopeStatement* currentScope = NULL);

lookupFunctionSymbolInParentScopes overloads

lookupNamedTypeInParentScopes
SgType* lookupNamedTypeInParentScopes(std::string const& 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.

lookupNamespaceSymbolInParentScopes
SgNamespaceSymbol* lookupNamespaceSymbolInParentScopes(SgName const& name, SgScopeStatement* currentScope = NULL);

lookupNonrealSymbolInParentScopes
SgNonrealSymbol* lookupNonrealSymbolInParentScopes(SgName const& name, SgScopeStatement* currentScope = NULL, SgTemplateParameterPtrList* templateParameterList = NULL, SgTemplateArgumentPtrList* templateArgumentList = NULL);

lookupSymbolInParentScopes
SgSymbol* lookupSymbolInParentScopes(SgName const& name, SgScopeStatement* currentScope = NULL, SgTemplateParameterPtrList* templateParameterList = NULL, SgTemplateArgumentPtrList* templateArgumentList = NULL);

lookupSymbolInParentScopesForAstCopyFixup
SgSymbol* lookupSymbolInParentScopesForAstCopyFixup(SgName const& name, SgScopeStatement* currentScope, VariantT requestedSymbolKind, SgType const* type = NULL, SgTemplateParameterPtrList* templateParameterList = NULL, SgTemplateArgumentPtrList* templateArgumentList = NULL);

Parent‐scope lookup used only by AST snippet‐copy fixup. Recursive base‐class search is explicit to this call and never changes global state.

lookupSymbolInParentScopesForNameQualification
SgSymbol* lookupSymbolInParentScopesForNameQualification(SgName const& name, SgScopeStatement* currentScope, VariantT requestedSymbolKind, SgType const* type, SgTemplateParameterPtrList* templateParameterList, SgTemplateArgumentPtrList* templateArgumentList, SgUnorderedNodeSet const& visibleAliasCausalNodes);

Parent‐scope lookup for one name‐qualification invocation. The caller must supply the exact symbol kind and its invocation‐owned alias visibility set.

lookupSymbolInParentScopesIgnoringAliasSymbols
SgSymbol* lookupSymbolInParentScopesIgnoringAliasSymbols(SgName const& name, SgScopeStatement* currentScope = NULL, SgTemplateParameterPtrList* templateParameterList = NULL, SgTemplateArgumentPtrList* templateArgumentList = NULL);

utility functions for symbol tables

lookupTemplateClassSymbolInParentScopes
SgTemplateClassSymbol* lookupTemplateClassSymbolInParentScopes(SgName const& name, SgTemplateParameterPtrList* templateParameterList, SgTemplateArgumentPtrList* templateArgumentList, SgScopeStatement* cscope = NULL);

lookupTemplateFunctionSymbolInParentScopes
SgFunctionSymbol* lookupTemplateFunctionSymbolInParentScopes(SgName const& functionName, SgFunctionType* ftype, SgTemplateParameterPtrList* tplparams, SgScopeStatement* currentScope = NULL);

lookupTemplateMemberFunctionSymbolInParentScopes
SgFunctionSymbol* lookupTemplateMemberFunctionSymbolInParentScopes(SgName const& functionName, SgFunctionType* ftype, SgTemplateParameterPtrList* tplparams, SgScopeStatement* currentScope = NULL);

lookupTemplateVariableSymbolInParentScopes
SgTemplateVariableSymbol* lookupTemplateVariableSymbolInParentScopes(SgName const& name, SgTemplateParameterPtrList* tplparams, SgTemplateArgumentPtrList* tplargs, SgScopeStatement* currentScope = NULL);

lookupTypedefSymbolInParentScopes
SgTypedefSymbol* lookupTypedefSymbolInParentScopes(SgName const& name, SgScopeStatement* currentScope = NULL);

lookupVariableSymbolInParentScopes
SgVariableSymbol* lookupVariableSymbolInParentScopes(SgName const& name, SgScopeStatement* currentScope = NULL);

loopCollapsing
SgExprListExp* loopCollapsing(SgForStatement* target_loop, size_t collapsing_factor, SgStatement* setup_insertion_anchor = nullptr);

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

loopTiling
void loopTiling(SgForStatement* loopNest, std::vector<size_t> const& tileSizes);

loopTiling overloads

loopUnrolling
void loopUnrolling(SgForStatement* loop, size_t unrolling_factor);

Unroll a target loop by grouping exact source iterations. The checked implementation never synthesizes range, endpoint, or stride products.

makeSingleStatementBodyToBlock
SgBasicBlock* makeSingleStatementBodyToBlock(SgStatement* singleStmt);

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

mangleModifierType
std::string mangleModifierType(SgModifierType* type);

Generated mangled modifier types, include const, volatile,according to Itanium C++ ABI.

mangleScalarType
std::string mangleScalarType(SgType* type);

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

mangleType
std::string mangleType(SgType* type);

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

markNodeToBeUnparsed
void markNodeToBeUnparsed(SgNode* node, int physical_file_id);

markSubtreeToBeUnparsed
void markSubtreeToBeUnparsed(SgNode* root, int physical_file_id);

mergeAssignmentWithDeclaration
bool mergeAssignmentWithDeclaration(SgExprStatement* assign_stmt, SgVariableDeclaration* decl);

Merge an assignment into its upstream declaration statement. Callers should make sure the merge is semantically correct.

mergeDeclarationAndAssignment
bool mergeDeclarationAndAssignment(SgVariableDeclaration* decl, SgExprStatement* assign_stmt);

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.

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

moveCommentsToNewStatement
void moveCommentsToNewStatement(SgStatement* sourceStatement, std::vector<int> const& indexList, SgStatement* destinationStatement, bool destinationStatementPreceedsSourceStatement);

Relocate comments and CPP directives from one statement to another.

moveForStatementIncrementIntoBody
void moveForStatementIncrementIntoBody(SgForStatement* f);

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

moveStatementsBetweenBlocks
void moveStatementsBetweenBlocks(SgBasicBlock* sourceBlock, SgBasicBlock* targetBlock);

moveStatementsBetweenBlocks overloads

moveToSubdirectory
void moveToSubdirectory(std::string directoryName, SgFile* file);

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

moveUpInnerDanglingIfEndifDirective
int moveUpInnerDanglingIfEndifDirective(SgLocatedNode* lnode);

moveVariableDeclaration
void moveVariableDeclaration(SgVariableDeclaration* decl, SgScopeStatement* target_scope);

Move a variable declaration to a new scope, handle symbol, special scopes like For loop, etc.

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

nonrealTypeCarriesWrittenQualification
bool nonrealTypeCarriesWrittenQualification(SgNonrealType const* nonreal_type);

nonrealTypeHasSemanticQualificationChain
bool nonrealTypeHasSemanticQualificationChain(SgNonrealType const* nonreal_type);

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

normalizeCaseAndDefaultBlocks
bool normalizeCaseAndDefaultBlocks(SgSwitchStatement* switchStmt);

Normalize the structure of case and default blocks within a switch statement.

normalizeForLoopIncrement
void normalizeForLoopIncrement(SgForStatement* loop);

normalizeForLoopInitDeclaration
void 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

normalizeForLoopTest
void normalizeForLoopTest(SgForStatement* loop);

Validate a for loop's typed comparison without changing its inclusivity.

outputFileIds
void outputFileIds(SgNode* node);

outputGlobalFunctionTypeSymbolTable
void outputGlobalFunctionTypeSymbolTable();

Output function type symbols in global function type symbol table.

outputLocalSymbolTables
void outputLocalSymbolTables(SgNode* node);

Output the local symbol tables.

outputSharedNodes
void outputSharedNodes(SgNode* node);

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

preOrderCollectPreprocessingInfo
void preOrderCollectPreprocessingInfo(SgNode* current, std::vector<PreprocessingInfo*>& infoList, int depth);

prepareStatementInsertionAnchor
SgStatement* prepareStatementInsertionAnchor(SgStatement* targetStmt);

Normalize an attached statement into the exact lexical anchor used by a subsequent sibling insertion.

prependArg
SgVariableSymbol* prependArg(SgFunctionParameterList*, SgInitializedName*);

Prepend an argument to SgFunctionParameterList

prependStatement
void prependStatement(SgStatement* stmt, SgForInitStatement* for_init_stmt);

prependStatement overloads

prependStatementList
void prependStatementList(std::vector<SgStatement*> const& stmt, SgScopeStatement* scope);

Prepend a list of statements to the beginning of an explicit lexical scope.

printAST
void printAST(SgNode* node);

printAST overloads

printAST2TextFile
void printAST2TextFile(SgNode* node, std::string filename, bool printType = true);

printAST2TextFile overloads

printOutComments
void printOutComments(SgLocatedNode* locatedNode);

promoteSemanticOnlyNodeToGeneratedOutput
void promoteSemanticOnlyNodeToGeneratedOutput(SgLocatedNode* semanticNode, SgLocatedNode* exactOwner);

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.

publishClassMemberAccessAtLexicalBoundary
void publishClassMemberAccessAtLexicalBoundary(SgDeclarationStatement* declaration, SgClassDefinition* definition);

Publish and validate the effective access of a declaration at its exact structural position in a C++ class definition. Fresh builder declarations may arrive with an unclassified access modifier; source‐backed declarations must already agree with the surrounding access‐label stream.

publishGeneratedPreprocessingInfo
void publishGeneratedPreprocessingInfo(PreprocessingInfo* record, SgLocatedNode* exactOwner);

Publish a generated preprocessing record with one exact physical output owner. The record remains typed as a transformation; its Sg_File_Info keeps logical spelling provenance and stores physical output identity separately.

publishGeneratedSubtreeOutputOwner
void publishGeneratedSubtreeOutputOwner(SgNode* generatedSubtree, SgLocatedNode* exactOwner);

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.

publishGeneratedTrailingComment
void publishGeneratedTrailingComment(PreprocessingInfo* record, SgLocatedNode* exactOwner);

Publish a generated trailing comment whose explicit attachment is after the owner's syntax on the owner's current output line.

publishPreprocessingInfoPhysicalOutputOwner
void publishPreprocessingInfoPhysicalOutputOwner(PreprocessingInfo* record, SgLocatedNode* exactOwner);

Publish an existing preprocessing record at a new exact physical output owner. Source‐spelled records retain their logical spelling and semantic classification while their physical output identity changes; generated records are validated by publishGeneratedPreprocessingInfo().

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

rebindVariableReferencesAfterMove
void rebindVariableReferencesAfterMove(SgNode* root);

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.

rebuildSymbolTable
void rebuildSymbolTable(SgScopeStatement* scope);

Regenerate the symbol table.

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

recursivePrintCurrentAndParent
void recursivePrintCurrentAndParent(SgNode* n);

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

registerAstTeardownAtExit
void registerAstTeardownAtExit();

Register an AST teardown handler to run at process exit if cleanup was not invoked.

registerAstTeardownProject
void registerAstTeardownProject(SgProject* project);

Record a project for teardown when running exit handlers.

relocateAttachedPreprocessingInfoPhysicalOutputOwner
void relocateAttachedPreprocessingInfoPhysicalOutputOwner(PreprocessingInfo* record, SgLocatedNode* priorOwner, SgLocatedNode* exactOwner);

Relocate an already‐published preprocessing record whose typed output placement is the attached AST boundary. The record must identify priorOwner exactly; detached, shared, source‐position‐owned, or differently owned records are hard errors. Source/generated spelling provenance is immutable.

relocateGeneratedSubtreePhysicalOutputOwner
void relocateGeneratedSubtreePhysicalOutputOwner(SgNode* generatedSubtree, SgLocatedNode* priorOwner, SgLocatedNode* exactOwner);

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.

removeAllOriginalExpressionTrees
void removeAllOriginalExpressionTrees(SgNode* top);

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

removeConsecutiveLabels
void removeConsecutiveLabels(SgNode* top);

Remove consecutive labels

removeConst
SgType* removeConst(SgType* t);

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

removeJumpsToNextStatement
void removeJumpsToNextStatement(SgNode*);

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

removeLabeledGotos
void removeLabeledGotos(SgNode* top);

Remove labeled goto statements

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

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

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

replaceExpressionWithStatement
void replaceExpressionWithStatement(SgExpression* from, SageInterface::StatementGenerator* to);

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

replaceFunctionDefinitionWithDeclaration
SgDeclarationStatement* replaceFunctionDefinitionWithDeclaration(SgFunctionDeclaration* functionDefinition, bool movePreprocessingInfo = true);

Replace an exact defining function declaration with a legal declaration source surface. Free functions and member definitions written in their class are replaced by a newly built prototype. A member definition written outside its semantic class scope is replaced by SgEmptyDeclaration because a namespace‐scope qualified member prototype is ill‐formed C++. The removed definition remains semantically owned by its scope's SgAuxiliaryDeclarationList and its complete declaration family and symbol are preserved. Malformed or unsupported inputs are hard errors; this function never returns null.

replaceFunctionDefinitionsWithDeclarations
void replaceFunctionDefinitionsWithDeclarations(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.

replaceStatement
void replaceStatement(SgStatement* oldStmt, SgStatement* newStmt, bool movePreprocessinInfo = false);

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

replaceSubexpressionWithStatement
void replaceSubexpressionWithStatement(SgExpression* from, SageInterface::StatementGenerator* to);

Similar to replaceExpressionWithStatement, but with more restrictions. Assumptions: from is not within the test of a loop or ifStmt, not currently traversing from or the statement it is in

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

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

reportModifiedStatements
void reportModifiedStatements(std::string const& label, SgNode* node);

requireCanonicalVariableTemplatePrimary
SgTemplateVariableDeclaration* requireCanonicalVariableTemplatePrimary(SgTemplateVariableDeclaration* specialization, char const* context);

Return the canonical source variable template reached from a specialization after validating the complete, acyclic specialized‐template chain.

requireCheckedCanonicalLoopPlan
CheckedCanonicalLoopPlan requireCheckedCanonicalLoopPlan(SgForStatement* loop, char const* operation);

Build a checked loop plan without modifying or allocating into the AST.

requireCheckedLoopTilingPlan
CheckedLoopTilingPlan requireCheckedLoopTilingPlan(SgForStatement* outer, std::vector<size_t> const& tile_sizes, char const* operation = "loop‐tiling");

Validate a complete perfect nest and all tile sizes without mutation, then commit the planned strip‐mining transformations in place.

requireCheckedLoopUnrollPlan
CheckedLoopUnrollPlan requireCheckedLoopUnrollPlan(SgForStatement* loop, size_t factor, char const* operation = "loop‐unrolling");

Read‐only unroll planning and one atomic commit.

requireNamedTypeInParentScopes
SgType* requireNamedTypeInParentScopes(std::string const& type_name, SgScopeStatement* scope);

Return an existing named type or terminate if the current AST has no such declaration. This never synthesizes a placeholder declaration.

requireResolvedFunctionTemplateReference
SgFunctionDeclaration* requireResolvedFunctionTemplateReference(SgNonrealRefExp const* reference, char const* context);

Validate and return the exact callable denoted by a resolved function‐ template nonreal reference. This is a hard AST contract: the synthetic source‐spelling node, the real callable declaration, its canonical symbol, its function type, and both copies of the written arguments must agree.

requireResolvedVariableTemplateReference
SgInitializedName* requireResolvedVariableTemplateReference(SgNonrealRefExp const* reference, char const* context);

Validate and return the exact initialized name denoted by a resolved variable‐template nonreal reference. This is a hard AST contract: the synthetic source‐spelling node, the real specialization, its source template, its symbol, and both copies of the written arguments must agree.

requireStatementCanBeTransformed
void requireStatementCanBeTransformed(SgStatement* stmt);

Require exact physical/include ownership before mutating a statement in a token‐unparsed header. Ambiguous or unsupported ownership is a hard error.

requireTargetSizeType
SgType* requireTargetSizeType(SgNode const* context);

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

resetInternalMapsForTargetStatement
void resetInternalMapsForTargetStatement(SgStatement* sourceStatement, bool statementWillBeDetached = false);

resetMangledNameCache
void resetMangledNameCache(SgGlobal* globalScope);

resetModifiedLocatedNodes
void resetModifiedLocatedNodes(std::set<SgLocatedNode*> const& modifiedNodeSet);

Use the set of IR nodes and set the isModified flag in each IR node to true.

resetScopeNumbers
void resetScopeNumbers(SgFunctionDefinition* functionDeclaration);

Assigns unique numbers to each SgScopeStatement of a function.

reset_name_collision_map
void reset_name_collision_map();

Reset map variables used to support generateUniqueNameForUseAsIdentifier() function.

retireForLoopInitNormalization
void retireForLoopInitNormalization(SgForStatement* loop);

saveToPDF
void saveToPDF(SgNode* node);

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.

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

serialize
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

serialize_list
template<typename T> void serialize_list(T& plist, std::string T_name, std::string& prefix, bool hasRemaining, std::ostringstream& out, std::string& edgeLabel);

setAbbreviatedFunctionTemplateParameter
void setAbbreviatedFunctionTemplateParameter(SgTemplateParameter* param, bool is_abbreviated_placeholder = true);

setBaseTypeDefiningDeclaration
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

setCanonicalForLoopInclusiveComparison
void setCanonicalForLoopInclusiveComparison(SgForStatement* loop, bool increasing);

setCtorInitializerList
template<class actualMemberFunction> void setCtorInitializerList(actualMemberFunction* func, SgCtorInitializerList* ctorlist);

Publish an exactly constructed ctor‐initializer list for a member function.

setExtern
void setExtern(SgDeclarationStatement* stmt);

Set a declaration as extern

setFortranNumericLabel
void setFortranNumericLabel(SgStatement* stmt, int label_value, SgLabelSymbol::label_type_enum label_type, SgScopeStatement* label_scope);

Set a numerical label for a Fortran statement in its exact program‐unit label scope. SgLabelSymbol and SgLabelRefExp are created as needed.

setLhsOperand
void setLhsOperand(SgExpression* target, SgExpression* lhs);

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

setLoopBody
void setLoopBody(SgScopeStatement* loop, SgStatement* body);

setLoopCondition
void setLoopCondition(SgScopeStatement* loop, SgStatement* cond);

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

setLoopLowerBound
void setLoopLowerBound(SgNode* loop, SgExpression* lb);

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

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

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

setOneSourcePositionForTransformation
void setOneSourcePositionForTransformation(SgNode* root);

Set current node's source position as transformation generated

setOneSourcePositionNull
void setOneSourcePositionNull(SgNode* node);

Set current node's source position as NULL

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

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

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

setPragma
void setPragma(SgPragmaDeclaration* decl, SgPragma* pragma);

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

setRhsOperand
void setRhsOperand(SgExpression* target, SgExpression* rhs);

set left hand operand for binary expression

setSemanticOnlyFrontendSourcePosition
void setSemanticOnlyFrontendSourcePosition(SgLocatedNode* semanticNode);

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

setSourcePosition
void setSourcePosition(SgNode* node);

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

setSourcePositionAsTransformation
void setSourcePositionAsTransformation(SgNode* node);

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

setSourcePositionAtRootAndAllChildren
void setSourcePositionAtRootAndAllChildren(SgNode* root);

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

setSourcePositionForTransformation
void setSourcePositionForTransformation(SgNode* root);

Recursively set source position info(Sg_File_Info) as transformation generated

setStatic
void setStatic(SgDeclarationStatement* stmt);

Set a declaration as static

setTemplateParameterKeyword
void setTemplateParameterKeyword(SgTemplateParameter* param, SgTemplateParameter::template_parameter_keyword_enum kw);

set_name
int set_name(SgInitializedName* initializedNameNode, SgName new_name);

set_name of symbol in symbol table.

skipTranslateToUseCppDeclaration
bool skipTranslateToUseCppDeclaration(PreprocessingInfo* currentPreprocessingInfo);

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

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

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

Replace an expression with a temporary variable and an assignment statement

splitExpressionIntoBasicBlock
void splitExpressionIntoBasicBlock(SgExpression* expr);

Split long expressions into blocks of statements

splitVariableDeclaration
SgExprStatement* splitVariableDeclaration(SgVariableDeclaration* decl);

splitVariableDeclaration overloads

suggestNextNumericLabel
int suggestNextNumericLabel(SgFunctionDefinition* func_def);

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

tearDownAst
void tearDownAst(SgProject* project);

Explicitly tear down an AST and release global caches and memory pools. AST pointers are invalid after this call.

templateArgumentEquivalence
bool templateArgumentEquivalence(SgTemplateArgument* arg1, SgTemplateArgument* arg2);

Verify that 2 SgTemplateArgument are equivalent (same type, same expression, or same template declaration)

templateArgumentListEquivalence
bool templateArgumentListEquivalence(SgTemplateArgumentPtrList const& list1, SgTemplateArgumentPtrList const& list2);

Verify that 2 SgTemplateArgumentPtrList are equivalent.

templateDefinitionIsInClass
bool templateDefinitionIsInClass(SgTemplateInstantiationMemberFunctionDecl* memberFunctionDeclaration);

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

templateParameterEquivalence
bool templateParameterEquivalence(SgTemplateParameter* parameter1, SgTemplateParameter* parameter2);

Verify that two template parameters describe the same parameter identity.

templateParameterListEquivalence
bool templateParameterListEquivalence(SgTemplateParameterPtrList const& list1, SgTemplateParameterPtrList const& list2);

Verify that two template parameter lists describe the same signature.

transferSymbols
void transferSymbols(SgScopeStatement* from_scope, SgScopeStatement* to_scope, bool skip_label_symbols = true);

translateScopeToUseCppDeclarations
void translateScopeToUseCppDeclarations(SgScopeStatement* scope);

translateStatementToUseCppDeclarations
std::vector<SgC_PreprocessorDirectiveStatement*> translateStatementToUseCppDeclarations(SgStatement* statement, SgScopeStatement* scope);

translateToUseCppDeclarations
void translateToUseCppDeclarations(SgNode* n);

typeCarriesIntrinsicNonrealQualification
bool typeCarriesIntrinsicNonrealQualification(SgType const* type);

typeCarriesWrittenNonrealQualification
bool typeCarriesWrittenNonrealQualification(SgType const* type);

typeHasSemanticNonrealQualificationChain
bool typeHasSemanticNonrealQualificationChain(SgType const* type);

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

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

usualArithmeticConversionType
SgType* usualArithmeticConversionType(SgType* lhs, SgType* rhs, SgNode const* context);

Apply the C/C++ usual arithmetic conversions using the target ABI owned by context. Invalid, non‐arithmetic, or detached inputs are hard errors.

validateFortranCommonBlockRef
void validateFortranCommonBlockRef(SgFortranCommonBlockRefExp const* reference);

Enforce the semantic and exact‐source identity contract of a typed Fortran common‐block directive designator.

validateSymbolOwnership
void validateSymbolOwnership(SgNode* root);

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

whereAmI
void whereAmI(SgNode* node);

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

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

wrapFunction overloads

Variables

Name

Description

gensym_counter

An internal counter for generating unique SgName

local_name_collision_map

Global map of name collisions to support generateUniqueNameForUseAsIdentifier() function.

local_name_to_node_map

local_node_to_name_map

trans_records

Description

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.

Created with MrDocs