Skip to content

SageInterface

Functions that are useful when operating on the AST.

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.

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
DeferredTransformation Add, remove,and replace AST
OutputLocalSymbolTables
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
[[visibility("default")]] 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.
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
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] void appendExpression( SgExprListExp*, SgExpression*);
Append an expression to a SgExprListExp, set the parent pointer also
appendExpressionList
[[visibility("default")]] void appendExpressionList( SgExprListExp*, std::vector<SgExpression*> const&);
Append an expression list to a SgExprListExp, set the parent pointers also
appendStatement
[[visibility("default")]] void appendStatement( SgStatement* stmt, SgForInitStatement* for_init_stmt);
appendStatement overloads
appendStatementList
[[visibility("default")]] void appendStatementList( std::vector<SgStatement*> const& stmt, SgScopeStatement* scope);
Append a list of statements to the end of an explicit lexical scope.
appendStatementWithDependentDeclaration
[[visibility("default")]] void appendStatementWithDependentDeclaration( SgDeclarationStatement* decl, SgGlobal* scope, SgFunctionDeclaration* source_call_declaration, bool excludeHeaderFiles, std::vector<PreprocessingInfo> const& original_directives, std::vector<SgDeclarationStatement*> const& original_dependencies, SgSourceFile* original_source_file);
astIntersection
[[visibility("default")]] std::vector<SgNode*> astIntersection( SgNode* original, SgNode* copy, SgCopyHelp* help = NULL);
Compute the intersection set for two ASTs.
attachComment
[[visibility("default")]] 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
[[visibility("default")]] void beginDetachedForStatementConstruction( SgForStatement* statement, SgScopeStatement* exactOutputOwner);
beginDetachedFunctionParameterScopeConstruction
[[visibility("default")]] 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.
buildFunctionPrototype
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] void changeContinuesToGotos( SgStatement* stmt, SgLabelStatement* label);
Change continue statements in a given block of code to gotos to a label
checkSgNodePointers
[[visibility("default")]] void checkSgNodePointers();
checkTypesAreEqual
bool checkTypesAreEqual( SgType* typeA, SgType* typeB);
cleanupNontransformedBasicBlockNode
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] 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.
collectDependentDeclarations
[[visibility("default")]] std::vector<SgDeclarationStatement*> collectDependentDeclarations( SgStatement* stmt, bool includeHeaderDeclarations, int originalPhysicalFileId);
collectDirectIncludeSystemRoles
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] std::set<SgStatement*> collectTransformedStatements(SgNode* node);
This collects the statements that are marked as transformed (useful in debugging).
collectUseByAddressVariableRefs
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] void commitLoopTiling(CheckedLoopTilingPlan const& plan);
commitLoopUnrolling
[[visibility("default")]] void commitLoopUnrolling(CheckedLoopUnrollPlan const& plan);
completeDetachedForStatementConstruction
[[visibility("default")]] void completeDetachedForStatementConstruction(SgForStatement* statement);
completeDetachedFunctionParameterScopeConstruction
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] 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.
constraintExpressionEquivalence
[[visibility("default")]] bool constraintExpressionEquivalence( SgExpression const* left, SgExpression const* right);
containsUnknownType
[[visibility("default")]] bool containsUnknownType(SgType const* type);
Check if a type (or any nested type) is unknown/incomplete.
convertAllForsToWhiles
[[visibility("default")]] void convertAllForsToWhiles(SgNode* top);
convertForToWhile
[[visibility("default")]] void convertForToWhile(SgForStatement* f);
convertRefToInitializedName
[[visibility("default")]] 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
[[visibility("default")]] SgExpression* copyExpression(SgExpression* e);
Deep copy an expression
copyStatement
[[visibility("default")]] 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
[[visibility("default")]] 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.
cxxCompoundLiteralInitializerTypeMatchesObjectType
[[visibility("default")]] bool cxxCompoundLiteralInitializerTypeMatchesObjectType( SgType const* initializer, SgType const* object);
Match a compound literal's initializer value and object types, whose top-level cv qualifications may differ.
cxxNonTypeTemplateArgumentTypeConversionIsExact
[[visibility("default")]] 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.
cxxParameterTypeMatchesSemanticType
[[visibility("default")]] bool cxxParameterTypeMatchesSemanticType( SgType const* source, SgType const* semantic);
Match a written parameter type to its object type, including array and function parameter adjustment. Qualification on the object is preserved.
cxxSourceTemplateArgumentPrefixMatchesSemantic
[[visibility("default")]] 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.
cxxSourceTypeMatchesObjectType
[[visibility("default")]] bool cxxSourceTypeMatchesObjectType( SgType const* source, SgType const* semantic);
Match an object declaration, allowing completion of an omitted outer array bound.
cxxSourceTypeMatchesSemanticType
[[visibility("default")]] 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);
Compare declarations in structural preorder within one lexical AST. Identical declarations do not precede themselves. Both declarations must have unique traversal ownership paths to the same global or detached root.
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
[[visibility("default")]] SgNode* deepCopyNode(SgNode const* subtree);
Deep copy an arbitrary subtree
deepCopyNodeWithIdentityMap
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] void deleteAST(SgNode* node);
Notify indexes of the complete unprotected deletion boundary after proof, before destruction. The callback must not change AST references.
detachAllSymbolsFromScope
void detachAllSymbolsFromScope(SgScopeStatement* scope);
Detach every symbol through the symbol table's exact ownership API.
doLoopNormalization
[[visibility("default")]] void doLoopNormalization(SgFortranDo* loop);
Normalize a Fortran Do loop. Make the default increment expression (1) explicit
dumpInfo
[[visibility("default")]] void dumpInfo( SgNode* node, std::string desc = "");
Dump information about a SgNode for debugging
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
[[visibility("default")]] 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
[[visibility("default")]] SgBasicBlock* ensureBasicBlockAsBodyOfDoWhile(SgDoWhileStmt* ws);
Check if the body of a 'do .. while' statement is a SgBasicBlock, create one if not.
ensureBasicBlockAsBodyOfFor
[[visibility("default")]] SgBasicBlock* ensureBasicBlockAsBodyOfFor(SgForStatement* fs);
Check if the body of a 'for' statement is a SgBasicBlock, create one if not.
ensureBasicBlockAsBodyOfOmpBodyStmt
[[visibility("default")]] SgBasicBlock* ensureBasicBlockAsBodyOfOmpBodyStmt(SgOmpBodyStatement* ompbodyStmt);
Check if the body of a SgOmpBodyStatement is a SgBasicBlock, create one if not
ensureBasicBlockAsBodyOfSwitch
[[visibility("default")]] SgBasicBlock* ensureBasicBlockAsBodyOfSwitch(SgSwitchStatement* ws);
Check if the body of a 'switch' statement is a SgBasicBlock, create one if not.
ensureBasicBlockAsBodyOfWhile
[[visibility("default")]] SgBasicBlock* ensureBasicBlockAsBodyOfWhile(SgWhileStmt* ws);
Check if the body of a 'while' statement is a SgBasicBlock, create one if not.
ensureBasicBlockAsFalseBodyOfIf
[[visibility("default")]] 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
[[visibility("default")]] SgBasicBlock* ensureBasicBlockAsTrueBodyOfIf(SgIfStmt* ifs);
Check if the true body of a 'if' statement is a SgBasicBlock, create one if not.
ensureLocatedNodeFileInfoForTransformation
[[visibility("default")]] void ensureLocatedNodeFileInfoForTransformation(SgLocatedNode* locatedNode);
Ensure a located node has the file-info objects required before marking it as a transformation/output subtree.
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
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] SgOmpClauseBodyStatement* findEnclosingOmpClauseBodyStatement(SgStatement* s);
Find enclosing OpenMP clause body statement from s. If s is already one, return it directly.
findEnclosingSwitch
[[visibility("default")]] SgSwitchStatement* findEnclosingSwitch(SgStatement* s);
Find the closest switch outside a given statement (normally used for case and default statements)
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
[[visibility("default")]] 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
[[visibility("default")]] SgFunctionDeclaration* findMain(SgNode* currentNode);
top-down traversal from current node to find the main() function declaration
findSurroundingStatementFromSameFile
[[visibility("default")]] SgStatement* findSurroundingStatementFromSameFile( SgStatement* targetStmt, bool& surroundingStatementPreceedsTargetStatement);
Supporting function to comment relocation in insertStatement() and removeStatement().
findUnusedLabels
[[visibility("default")]] std::set<SgLabelStatement*> findUnusedLabels(SgNode* top);
Find unused labels which are not targets of any goto statements
fixFunctionDeclaration
[[visibility("default")]] void fixFunctionDeclaration( SgFunctionDeclaration* stmt, SgScopeStatement* scope);
Fix the symbol table and set scope (only if scope in declaration is not already set).
fixLabelStatement
[[visibility("default")]] void fixLabelStatement( SgLabelStatement* label_stmt, SgScopeStatement* scope);
Register a label once its scope is known. A null scope defers registration.
fixStatement
[[visibility("default")]] void fixStatement( SgStatement* stmt, SgScopeStatement* scope);
fixVariableDeclaration
[[visibility("default")]] void fixVariableDeclaration( SgVariableDeclaration* varDecl, SgScopeStatement* scope);
Publish a completed variable declaration's semantic scope and symbols.
fixupReferencesToSymbols
void fixupReferencesToSymbols( SgScopeStatement const* this_scope, SgScopeStatement* copy_scope, SgCopyHelp& help);
Construct a copied scope's symbols and map references to their exact copies.
forLoopNormalization
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] 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.
generateFileList
std::vector<SgFile*> generateFileList();
Returns STL vector of SgFile IR node pointers.
generateFunctionDefinitionsList
[[visibility("default")]] std::vector<SgFunctionDeclaration*> generateFunctionDefinitionsList(SgNode* node);
generateProjectName
[[visibility("default")]] std::string generateProjectName( SgProject const* project, bool supressSuffix = false);
Generate a project name from its 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
[[visibility("default")]] void getAllStatementsAtLine( SgSourceFile* sourceFile, int line, SgStatementPtrList& returnList);
Obtain all the queryed statement at line of a source file
getArrayElementCount
[[visibility("default")]] size_t getArrayElementCount(SgArrayType* t);
Calculate the number of elements of an array type with constant bounds.
getArrayElementType
[[visibility("default")]] SgType* getArrayElementType(SgType* t);
Get the element type of an array. It recursively find the base type for multi-dimension array types
getBoolType
[[visibility("default")]] SgType* getBoolType(SgNode* n);
Get the right bool type according to C or C++ language input
getClassTypeChainForMemberReference
[[visibility("default")]] std::list<SgClassType*> getClassTypeChainForMemberReference(SgExpression* refExp);
getConditionValue
SgExpression* getConditionValue(SgScopeStatement* stmt);
Return the converted predicate of IF, WHILE, FOR, or SWITCH; null only for consteval IF or an absent FOR condition. Declaration conditions own a separate predicate evaluated after their initializer.
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.
getDefaultDestructor
[[visibility("default")]] 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
[[visibility("default")]] int getDimensionCount(SgType* t);
Get the number of dimensions of an array type
getElementType
[[visibility("default")]] 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
[[visibility("default")]] SgClassDeclaration* getEnclosingClassDeclaration(SgNode* astNode);
Get the closest class declaration enclosing the specified AST node,
getEnclosingClassDefinition
[[visibility("default")]] SgClassDefinition* getEnclosingClassDefinition( SgNode* astnode, bool const includingSelf = false);
Get the closest class definition enclosing the specified AST node,
getEnclosingExprListExp
[[visibility("default")]] SgExprListExp* getEnclosingExprListExp( SgNode* astNode, bool const includingSelf = false);
Get the enclosing SgExprListExp (used as part of function argument index evaluation in subexpressions).
getEnclosingFileNode
[[visibility("default")]] SgFile* getEnclosingFileNode(SgNode* astNode);
get the SgFile node from current node
getEnclosingFunctionDeclaration
[[visibility("default")]] SgFunctionDeclaration* getEnclosingFunctionDeclaration( SgNode* astNode, bool const includingSelf = false);
Find the enclosing function declaration, including its derived instances like isSgProcedureHeaderStatement, isSgProgramHeaderStatement, and isSgMemberFunctionDeclaration.
getEnclosingFunctionDefinition
[[visibility("default")]] SgFunctionDefinition* getEnclosingFunctionDefinition( SgNode* astNode, bool const includingSelf = false);
getEnclosingModuleStatement
[[visibility("default")]] 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
[[visibility("default")]] SgFunctionDefinition* getEnclosingProcedure( SgNode* n, bool const includingSelf = false);
Find the function definition
getEnclosingScope
[[visibility("default")]] SgScopeStatement* getEnclosingScope( SgNode* n, bool const includingSelf = false);
Get the enclosing scope from a node n
getEnclosingSourceFile
[[visibility("default")]] SgSourceFile* getEnclosingSourceFile( SgNode const* n, bool const includingSelf = false);
Find enclosing source file node
getEnclosingStatement
[[visibility("default")]] SgStatement* getEnclosingStatement(SgNode* n);
Find the closest enclosing statement, including the given node
getFirstGlobalScope
[[visibility("default")]] SgGlobal* getFirstGlobalScope(SgProject* project);
return the first global scope under current project
getFirstInitializedName
[[visibility("default")]] SgInitializedName* getFirstInitializedName(SgVariableDeclaration* decl);
Get the first initialized name of a declaration statement
getFirstStatement
[[visibility("default")]] 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
[[visibility("default")]] SgStatement* getFirstStatementAtLine( SgSourceFile* sourceFile, int line);
Obtain the first queryed statement at line of a source file
getFirstVarSym
[[visibility("default")]] SgVariableSymbol* getFirstVarSym(SgVariableDeclaration* decl);
Get the variable symbol for the first initialized name of a declaration stmt.
getFirstVarType
[[visibility("default")]] 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.
getFortranProgramUnitSymbolTableKey
[[visibility("default")]] 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
[[visibility("default")]] std::set<SgNode*> getFrontendSpecificNodes();
getFunctionDeclaration
[[visibility("default")]] SgFunctionDeclaration* getFunctionDeclaration(SgFunctionCallExp* functionCallExp);
getGlobalScope
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] SgStatement* getLastStatement(SgScopeStatement* scope);
get the last statement within a scope, return NULL if it does not exit
getLiveVariables
[[visibility("default")]] 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
[[visibility("default")]] SgStatement* getLoopBody(SgScopeStatement* loop);
Routines to get and set the body of a loop
getLoopCondition
[[visibility("default")]] SgStatement* getLoopCondition(SgScopeStatement* loop);
Routines to get the condition of a loop. It recognize While-loop, For-loop, and Do-While-loop
getLoopIndexVariable
[[visibility("default")]] SgInitializedName* getLoopIndexVariable(SgNode* loop);
Return the loop index variable for a for loop
getMangledNameFromCache
std::string getMangledNameFromCache(SgNode* astNode);
getNextStatement
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] SgProject* getProject();
Get the current SgProject IR Node.
getScope
[[visibility("default")]] 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
getTargetFileTypeWithCopyMap
SgType* getTargetFileTypeWithCopyMap( SgType* type, SgScopeStatement* scope, SgCopyHelp::copiedNodeMapType const& identities);
getTemplateParameterKeyword
[[visibility("default")]] SgTemplateParameter::template_parameter_keyword_enum getTemplateParameterKeyword(SgTemplateParameter* param);
getTypeName
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] bool hasSameGlobalScope( SgStatement* statement_1, SgStatement* statement_2);
This is supporting the recognition of functions in header files from two different ASTs
hasSemanticOnlyFrontendSourcePosition
[[visibility("default")]] 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
[[visibility("default")]] 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.
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
[[visibility("default")]] PreprocessingInfo* insertHeader( std::string const& filename, PreprocessingInfo::RelativePositionType position, bool isSystemHeader, SgScopeStatement* scope);
insertHeader overloads
insertStatement
[[visibility("default")]] 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
[[visibility("default")]] void insertStatementAfter( SgStatement* targetStmt, SgStatement* newStmt, bool autoMovePreprocessingInfo = true);
Insert a statement after a target statement, Move around preprocessing info automatically by default
insertStatementAfterLastDeclaration
[[visibility("default")]] void insertStatementAfterLastDeclaration( std::vector<SgStatement*> stmt_list, SgScopeStatement* scope);
insertStatementAfterLastDeclaration overloads
insertStatementBefore
[[visibility("default")]] void insertStatementBefore( SgStatement* targetStmt, SgStatement* newStmt, bool autoMovePreprocessingInfo = true);
Insert a statement before a target statement
insertStatementBeforeFirstNonDeclaration
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] void insertStatementListAfter( SgStatement* targetStmt, std::vector<SgStatement*> const& newStmt);
Insert a list of statements after a target statement
insertStatementListBefore
[[visibility("default")]] void insertStatementListBefore( SgStatement* targetStmt, std::vector<SgStatement*> const& newStmts);
Insert a list of statements before a target statement
insertStatementListBeforeFirstNonDeclaration
[[visibility("default")]] 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
[[visibility("default")]] bool insideHeader(SgLocatedNode* node);
Check if a node is from a header file
insideSystemHeader
[[visibility("default")]] bool insideSystemHeader(SgLocatedNode* node);
Check if a node is from a system header file
instrumentEndOfFunction
[[visibility("default")]] 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
[[visibility("default")]] bool isAbbreviatedFunctionTemplateParameter(SgTemplateParameter* param);
isAddressOfCurrentObjectDataMemberReference
[[visibility("default")]] bool isAddressOfCurrentObjectDataMemberReference(SgVarRefExp* varRefExp);
Distinguish ordinary member addresses from pointers to members using the address expression's typed operand form, including dependent template expressions and transformed expressions.
isAddressTaken
[[visibility("default")]] bool isAddressTaken(SgExpression* refExp);
isAncestor
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] bool isCallToParticularFunction( SgFunctionDeclaration* decl, SgExpression* e);
isCanonicalDoLoop
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] bool isConstType(SgType* t);
isConstantFalse
[[visibility("default")]] bool isConstantFalse(SgExpression* e);
Check if a bool or int constant expression evaluates to be a false value
isConstantTrue
[[visibility("default")]] bool isConstantTrue(SgExpression* e);
Check if a bool or int constant expression evaluates to be a true value
isCopyConstructible
[[visibility("default")]] bool isCopyConstructible(SgType* type);
Is a type copy constructible? This may not quite work properly.
isDataMemberReference
[[visibility("default")]] bool isDataMemberReference(SgVarRefExp* varRefExp);
isDefaultConstructible
[[visibility("default")]] bool isDefaultConstructible(SgType* type);
Is a type default constructible? This may not quite work properly.
isEqualToIntConst
[[visibility("default")]] bool isEqualToIntConst( SgExpression* e, int value);
Compare AST nodes, subtree, etc
isEquivalentFunctionType
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] bool isExtern(SgDeclarationStatement* stmt);
Check if a declaration has an "extern" modifier
isFortranProgramUnitWithoutSourceName
[[visibility("default")]] 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.
isFunctionPrototypeRefinement
[[visibility("default")]] bool isFunctionPrototypeRefinement( SgFunctionType const* prior, SgFunctionType const* current);
isInSubTree
[[visibility("default")]] bool isInSubTree( SgExpression* subtree, SgExpression* exp);
isIndexOperator
bool isIndexOperator(SgExpression* exp);
isLambdaCapturedVariable
[[visibility("default")]] bool isLambdaCapturedVariable(SgVarRefExp* varRef);
check if a variable reference is this->a[i]inside of a lambda function
isLambdaFunction
[[visibility("default")]] bool isLambdaFunction(SgFunctionDeclaration* func);
Check if a function declaration is a C++11 lambda function
isLastStatement
[[visibility("default")]] bool isLastStatement(SgStatement* stmt);
Check if a statement is the last statement within its closed scope
isLoopIndexVariable
[[visibility("default")]] 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
[[visibility("default")]] bool isMain(SgNode const* node);
Check if a SgNode is a main() function declaration
isMemberFunctionMemberReference
[[visibility("default")]] bool isMemberFunctionMemberReference(SgMemberFunctionRefExp* memberFunctionRefExp);
isMutable
[[visibility("default")]] bool isMutable(SgInitializedName* name);
True if an SgInitializedName is "mutable' (has storage modifier set)
isNonconstReference
[[visibility("default")]] bool isNonconstReference(SgType* t);
Is this type a non-constant reference type? (Handles typedefs correctly)
isOmpStatement
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] bool isPointerType(SgType* t);
Is this type a pointer type? (Handles typedefs correctly)
isPostfixOperator
bool isPostfixOperator(SgExpression* exp);
isPrefixOperator
bool isPrefixOperator(SgExpression* exp);
Classify a call's exact source operator surface.
isPrototypeInScope
bool isPrototypeInScope( SgScopeStatement* scope, SgFunctionDeclaration* functionDeclaration, SgDeclarationStatement* startingAtDeclaration);
isPureVirtualClass
[[visibility("default")]] 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
[[visibility("default")]] bool isReferenceType(SgType* t);
Is this type a const or non-const reference type? (Handles typedefs correctly)
isRemovableStatement
[[visibility("default")]] bool isRemovableStatement(SgStatement* s);
isRestrictType
[[visibility("default")]] bool isRestrictType(SgType* t);
Is this a restrict type?
isScalarType
[[visibility("default")]] 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
[[visibility("default")]] bool isStatic(SgDeclarationStatement* stmt);
Check if a declaration has a "static' modifier
isStrictIntegerType
[[visibility("default")]] 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
[[visibility("default")]] bool isStructDeclaration(SgNode* node);
Check if a SgNode is a declaration for a structure
isStructType
[[visibility("default")]] 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);
Compare node kinds, nesting, and null child positions in two ASTs.
isTemplateInstantiationNode
[[visibility("default")]] bool isTemplateInstantiationNode(SgNode* node);
isUnionDeclaration
[[visibility("default")]] bool isUnionDeclaration(SgNode* node);
Check if a SgNode is a declaration for a union
isUseByAddressVariableRef
[[visibility("default")]] 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
[[visibility("default")]] bool isValidFortranSourceIdentifier(std::string const& name);
Return whether a spelling is a valid Fortran source identifier.
isVolatileType
[[visibility("default")]] bool isVolatileType(SgType* t);
Is this a volatile type?
is_C99_language
[[visibility("default")]] bool is_C99_language();
is_CAF_language
[[visibility("default")]] bool is_CAF_language();
is_C_language
[[visibility("default")]] bool is_C_language();
version, language properties of current AST.
is_Cuda_language
[[visibility("default")]] bool is_Cuda_language();
is_Cxx_family_language
[[visibility("default")]] bool is_Cxx_family_language();
is_Cxx_language
[[visibility("default")]] bool is_Cxx_language();
is_Fortran_language
[[visibility("default")]] bool is_Fortran_language();
is_OpenCL_language
[[visibility("default")]] bool is_OpenCL_language();
is_OpenMP_language
[[visibility("default")]] bool is_OpenMP_language();
is_language_case_insensitive
[[visibility("default")]] bool is_language_case_insensitive();
is_mixed_C_and_Cxx_language
[[visibility("default")]] bool is_mixed_C_and_Cxx_language();
is_mixed_Fortran_and_C_and_Cxx_language
[[visibility("default")]] bool is_mixed_Fortran_and_C_and_Cxx_language();
is_mixed_Fortran_and_C_language
[[visibility("default")]] bool is_mixed_Fortran_and_C_language();
is_mixed_Fortran_and_Cxx_language
[[visibility("default")]] bool is_mixed_Fortran_and_Cxx_language();
language_may_contain_nondeclarations_in_scope
[[visibility("default")]] bool language_may_contain_nondeclarations_in_scope();
listHeaderFiles
[[visibility("default")]] void listHeaderFiles(SgIncludeFile* includeFile);
return path prefix for subtree of include files.
lookupClassSymbolInParentScopes
[[visibility("default")]] SgClassSymbol* lookupClassSymbolInParentScopes( SgName const& name, SgScopeStatement* currentScope = NULL, SgTemplateArgumentPtrList* templateArgumentList = NULL);
lookupEnumSymbolInParentScopes
[[visibility("default")]] SgEnumSymbol* lookupEnumSymbolInParentScopes( SgName const& name, SgScopeStatement* currentScope = NULL);
lookupFortranCommonBlockObject
[[visibility("default")]] 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
[[visibility("default")]] SgFunctionSymbol* lookupFunctionSymbolInParentScopes( SgName const& functionName, SgScopeStatement* currentScope = NULL);
lookupFunctionSymbolInParentScopes overloads
lookupNamedTypeInParentScopes
[[visibility("default")]] 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
[[visibility("default")]] SgNamespaceSymbol* lookupNamespaceSymbolInParentScopes( SgName const& name, SgScopeStatement* currentScope = NULL);
lookupSymbolInParentScopes
[[visibility("default")]] SgSymbol* lookupSymbolInParentScopes( SgName const& name, SgScopeStatement* currentScope = NULL, SgTemplateParameterPtrList* templateParameterList = NULL, SgTemplateArgumentPtrList* templateArgumentList = NULL);
Find a symbol by name in the current or an ancestor scope, starting from the top of ScopeStack when no scope is supplied.
lookupSymbolInParentScopesForAstCopyFixup
[[visibility("default")]] 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
[[visibility("default")]] 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.
lookupTemplateClassSymbolInParentScopes
[[visibility("default")]] SgTemplateClassSymbol* lookupTemplateClassSymbolInParentScopes( SgName const& name, SgTemplateParameterPtrList* templateParameterList, SgTemplateArgumentPtrList* templateArgumentList, SgScopeStatement* cscope = NULL);
lookupTemplateFunctionSymbolInParentScopes
[[visibility("default")]] SgFunctionSymbol* lookupTemplateFunctionSymbolInParentScopes( SgName const& functionName, SgFunctionType* ftype, SgTemplateParameterPtrList* tplparams, SgScopeStatement* currentScope = NULL);
lookupTemplateMemberFunctionSymbolInParentScopes
[[visibility("default")]] SgFunctionSymbol* lookupTemplateMemberFunctionSymbolInParentScopes( SgName const& functionName, SgFunctionType* ftype, SgTemplateParameterPtrList* tplparams, SgScopeStatement* currentScope = NULL);
lookupTemplateVariableSymbolInParentScopes
[[visibility("default")]] SgTemplateVariableSymbol* lookupTemplateVariableSymbolInParentScopes( SgName const& name, SgTemplateParameterPtrList* tplparams, SgTemplateArgumentPtrList* tplargs, SgScopeStatement* currentScope = NULL);
lookupTypedefSymbolInParentScopes
[[visibility("default")]] SgTypedefSymbol* lookupTypedefSymbolInParentScopes( SgName const& name, SgScopeStatement* currentScope = NULL);
lookupVariableSymbolInParentScopes
[[visibility("default")]] SgVariableSymbol* lookupVariableSymbolInParentScopes( SgName const& name, SgScopeStatement* currentScope = NULL);
loopCollapsing
SgExprListExp* loopCollapsing( SgForStatement* target_loop, size_t collapsing_factor, SgStatement* setup_insertion_anchor = nullptr);
loopInterchange
[[visibility("default")]] 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
[[visibility("default")]] void loopTiling( SgForStatement* loopNest, std::vector<size_t> const& tileSizes);
loopTiling overloads
loopUnrolling
[[visibility("default")]] 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.
markNodeToBeUnparsed
void markNodeToBeUnparsed( SgNode* node, int physical_file_id);
markSubtreeToBeUnparsed
void markSubtreeToBeUnparsed( SgNode* root, int physical_file_id);
materializeTypeWithCopyMap
SgType* materializeTypeWithCopyMap( SgType* type, SgCopyHelp& help, bool copyOwnedSyntax = true);
mergeAssignmentWithDeclaration
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] void moveCommentsToNewStatement( SgStatement* sourceStatement, std::vector<int> const& indexList, SgStatement* destinationStatement, bool destinationStatementPreceedsSourceStatement);
Relocate comments and CPP directives from one statement to another.
moveForStatementIncrementIntoBody
[[visibility("default")]] void moveForStatementIncrementIntoBody(SgForStatement* f);
movePreprocessingInfo
[[visibility("default")]] 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
[[visibility("default")]] void moveStatementsBetweenBlocks( SgBasicBlock* sourceBlock, SgBasicBlock* targetBlock);
moveStatementsBetweenBlocks overloads
moveUpInnerDanglingIfEndifDirective
[[visibility("default")]] int moveUpInnerDanglingIfEndifDirective(SgLocatedNode* lnode);
moveVariableDeclaration
[[visibility("default")]] void moveVariableDeclaration( SgVariableDeclaration* decl, SgScopeStatement* target_scope);
Move a variable declaration to a new scope, handle symbol, special scopes like For loop, etc.
moveVariableDeclarationGroup
[[visibility("default")]] void moveVariableDeclarationGroup( SgDeclarationGroupStatement* group, SgBasicBlock* target);
Move a source group of variable declarations atomically into a block.
myRemoveStatement
[[visibility("default")]] 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
[[visibility("default")]] bool nonrealTypeCarriesWrittenQualification(SgNonrealType const* nonreal_type);
nonrealTypeHasSemanticQualificationChain
[[visibility("default")]] bool nonrealTypeHasSemanticQualificationChain(SgNonrealType const* nonreal_type);
normalizeArrowExpWithAddressOfLeftOperand
[[visibility("default")]] 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
[[visibility("default")]] bool normalizeCaseAndDefaultBlocks(SgSwitchStatement* switchStmt);
Normalize the structure of case and default blocks within a switch statement.
normalizeForLoopIncrement
[[visibility("default")]] void normalizeForLoopIncrement(SgForStatement* loop);
normalizeForLoopInitDeclaration
[[visibility("default")]] 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
[[visibility("default")]] void normalizeForLoopTest(SgForStatement* loop);
Validate a for loop's typed comparison without changing its inclusivity.
outputGlobalFunctionTypeSymbolTable
void outputGlobalFunctionTypeSymbolTable();
Output function type symbols in global function type symbol table.
outputLocalSymbolTables
[[visibility("default")]] void outputLocalSymbolTables(SgNode* node);
Output the local symbol tables.
pastePreprocessingInfo
[[visibility("default")]] 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
[[visibility("default")]] void preOrderCollectPreprocessingInfo( SgNode* current, std::vector<PreprocessingInfo*>& infoList, int depth);
prepareStatementInsertionAnchor
[[visibility("default")]] SgStatement* prepareStatementInsertionAnchor(SgStatement* targetStmt);
Normalize an attached statement into the exact lexical anchor used by a subsequent sibling insertion.
prepareTemplateArgumentCopy
void prepareTemplateArgumentCopy( SgTemplateArgument const* argument, SgCopyHelp& help);
prepareTemplateParameterTypeCopy
void prepareTemplateParameterTypeCopy( SgTemplateParameter const* parameter, SgCopyHelp& help);
prependArg
[[visibility("default")]] SgVariableSymbol* prependArg( SgFunctionParameterList*, SgInitializedName*);
Prepend an argument to SgFunctionParameterList
prependStatement
[[visibility("default")]] void prependStatement( SgStatement* stmt, SgForInitStatement* for_init_stmt);
prependStatement overloads
prependStatementList
[[visibility("default")]] void prependStatementList( std::vector<SgStatement*> const& stmt, SgScopeStatement* scope);
Prepend a list of statements to the beginning of an explicit lexical scope.
printAST2TextFile
void printAST2TextFile( SgNode* node, char const* filename, bool printType = true);
Pretty print AST horizontally, output to a specified text file. If printType is set to false, don't print out type info.
promoteSemanticOnlyNodeToGeneratedOutput
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] 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.
recordNormalizations
[[visibility("default")]] 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
[[visibility("default")]] void registerAstTeardownAtExit();
Register an AST teardown handler to run at process exit if cleanup was not invoked.
registerAstTeardownProject
[[visibility("default")]] void registerAstTeardownProject(SgProject* project);
Record a project for teardown when running exit handlers.
relocateAttachedPreprocessingInfoPhysicalOutputOwner
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] void removeAllOriginalExpressionTrees(SgNode* top);
Delete exactly owned source-provenance trees before transforming their semantic expression owners.
removeConsecutiveLabels
[[visibility("default")]] 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
[[visibility("default")]] void removeJumpsToNextStatement(SgNode*);
Remove jumps whose label is immediately after the jump. Used to clean up inlined code fragments.
removeLabeledGotos
[[visibility("default")]] void removeLabeledGotos(SgNode* top);
Remove labeled goto statements
removeStatement
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] void replaceExpressionWithStatement( SgExpression* from, SageInterface::StatementGenerator* to);
Replace a given expression with a list of statements produced by a generator
replaceFunctionDefinitionWithDeclaration
[[visibility("default")]] 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.
replaceStatement
[[visibility("default")]] void replaceStatement( SgStatement* oldStmt, SgStatement* newStmt, bool movePreprocessinInfo = false);
Replace a statement with another. Move preprocessing information from oldStmt to newStmt if requested.
replaceSubexpressionWithStatement
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] 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.
requireCanonicalVariableTemplatePrimary
[[visibility("default")]] 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
[[visibility("default")]] CheckedCanonicalLoopPlan requireCheckedCanonicalLoopPlan( SgForStatement* loop, char const* operation);
Build a checked loop plan without modifying or allocating into the AST.
requireCheckedLoopTilingPlan
[[visibility("default")]] 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
[[visibility("default")]] CheckedLoopUnrollPlan requireCheckedLoopUnrollPlan( SgForStatement* loop, size_t factor, char const* operation = "loop-unrolling");
Read-only unroll planning and one atomic commit.
requireNamedTypeInParentScopes
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] 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.
requireTargetDefaultPointerSizeBits
[[visibility("default")]] unsigned int requireTargetDefaultPointerSizeBits(SgNode const* context);
requireTargetFloatingDomain
[[visibility("default")]] void requireTargetFloatingDomain( SgType* type, SgNode const* context, unsigned int& precision, int& max_exponent);
requireTargetIntegerDomain
[[visibility("default")]] void requireTargetIntegerDomain( SgType* type, SgNode const* context, bool& is_unsigned, unsigned int& width);
requireTargetScalarSizeBits
[[visibility("default")]] unsigned int requireTargetScalarSizeBits( SgType* type, SgNode const* context);
requireTargetSizeType
[[visibility("default")]] 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
[[visibility("default")]] void resetInternalMapsForTargetStatement( SgStatement* sourceStatement, bool statementWillBeDetached = false);
resetMangledNameCache
void resetMangledNameCache(SgGlobal* globalScope);
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.
retireBasicBlockNormalization
[[visibility("default")]] void retireBasicBlockNormalization(SgBasicBlock* block);
retireForLoopInitNormalization
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] void setExtern(SgDeclarationStatement* stmt);
Set a declaration as extern
setFortranNumericLabel
[[visibility("default")]] 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.
setLoopBody
[[visibility("default")]] void setLoopBody( SgScopeStatement* loop, SgStatement* body);
setLoopCondition
[[visibility("default")]] void setLoopCondition( SgScopeStatement* loop, SgStatement* cond);
Set the condition statement of a loop, including While-loop, For-loop, and Do-While-loop.
setLoopLowerBound
[[visibility("default")]] void setLoopLowerBound( SgNode* loop, SgExpression* lb);
Set the lower bound of a loop header for (i=lb; ...)
setLoopStride
[[visibility("default")]] 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
[[visibility("default")]] 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
[[visibility("default")]] void setOneSourcePositionForTransformation(SgNode* root);
Set current node's source position as transformation generated
setOneSourcePositionNull
[[visibility("default")]] void setOneSourcePositionNull(SgNode* node);
Set current node's source position as NULL
setOperand
[[visibility("default")]] void setOperand( SgExpression* target, SgExpression* operand);
Set one expression operand and its parent.
setParameterList
template<class actualFunction> void setParameterList( actualFunction* func, SgFunctionParameterList* paralist);
Install a builder's parameter list and publish its exact declaration links.
setPragma
[[visibility("default")]] void setPragma( SgPragmaDeclaration* decl, SgPragma* pragma);
Set a pragma of a pragma declaration. handle memory release for preexisting pragma, and set parent pointer.
setSemanticOnlyFrontendSourcePosition
[[visibility("default")]] 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
[[visibility("default")]] void setSourcePosition(SgNode* node);
Set the source code positon for the current (input) node.
setSourcePositionAsTransformation
void setSourcePositionAsTransformation(SgNode* node);
setSourcePositionAtRootAndAllChildren
[[visibility("default")]] void setSourcePositionAtRootAndAllChildren(SgNode* root);
Set the source code positon for the subtree (including the root).
setSourcePositionForTransformation
[[visibility("default")]] void setSourcePositionForTransformation(SgNode* root);
Recursively set source position info(Sg_File_Info) as transformation generated
setStatic
[[visibility("default")]] void setStatic(SgDeclarationStatement* stmt);
Set a declaration as static
setTemplateParameterKeyword
[[visibility("default")]] void setTemplateParameterKeyword( SgTemplateParameter* param, SgTemplateParameter::template_parameter_keyword_enum kw);
set_name
[[visibility("default")]] int set_name( SgInitializedName* initializedNameNode, SgName new_name);
set_name of symbol in symbol table.
sortSgNodeListBasedOnAppearanceOrderInSource
[[visibility("default")]] std::vector<SgDeclarationStatement*> sortSgNodeListBasedOnAppearanceOrderInSource(std::vector<SgDeclarationStatement*> const& nodevec);
Reorder a list of declaration statements based on their appearance order in source files
splitExpression
[[visibility("default")]] SgAssignInitializer* splitExpression( SgExpression* from, std::string newName = "");
Replace an expression with a temporary variable and an assignment statement
splitExpressionIntoBasicBlock
[[visibility("default")]] void splitExpressionIntoBasicBlock(SgExpression* expr);
Split long expressions into blocks of statements
splitVariableDeclaration
[[visibility("default")]] SgExprStatement* splitVariableDeclaration(SgVariableDeclaration* decl);
splitVariableDeclaration overloads
suggestNextNumericLabel
[[visibility("default")]] int suggestNextNumericLabel(SgFunctionDefinition* func_def);
Suggest next usable (non-conflicting) numeric label value for a Fortran function definition scope
tearDownAst
[[visibility("default")]] void tearDownAst(SgProject* project);
Explicitly tear down an AST and release global caches and memory pools. AST pointers are invalid after this call.
templateArgumentEquivalence
[[visibility("default")]] bool templateArgumentEquivalence( SgTemplateArgument* arg1, SgTemplateArgument* arg2);
Verify that 2 SgTemplateArgument are equivalent (same type, same expression, or same template declaration)
templateArgumentListEquivalence
[[visibility("default")]] bool templateArgumentListEquivalence( SgTemplateArgumentPtrList const& list1, SgTemplateArgumentPtrList const& list2);
Verify that 2 SgTemplateArgumentPtrList are equivalent.
templateDefinitionIsInClass
[[visibility("default")]] bool templateDefinitionIsInClass(SgTemplateInstantiationMemberFunctionDecl* memberFunctionDeclaration);
Return true if template definition is in the class, false if outside of class.
templateExpressionEquivalence
[[visibility("default")]] bool templateExpressionEquivalence( SgExpression const* left, SgExpression const* right);
templateParameterEquivalence
[[visibility("default")]] bool templateParameterEquivalence( SgTemplateParameter* parameter1, SgTemplateParameter* parameter2);
Verify that two template parameters describe the same parameter identity.
templateParameterListEquivalence
[[visibility("default")]] bool templateParameterListEquivalence( SgTemplateParameterPtrList const& list1, SgTemplateParameterPtrList const& list2);
Verify that two template parameter lists describe the same signature.
transferSymbols
[[visibility("default")]] void transferSymbols( SgScopeStatement* from_scope, SgScopeStatement* to_scope, bool skip_label_symbols = true);
typeCarriesIntrinsicNonrealQualification
[[visibility("default")]] bool typeCarriesIntrinsicNonrealQualification(SgType const* type);
typeCarriesWrittenNonrealQualification
[[visibility("default")]] bool typeCarriesWrittenNonrealQualification(SgType const* type);
typeHasSemanticNonrealQualificationChain
[[visibility("default")]] bool typeHasSemanticNonrealQualificationChain(SgType const* type);
unnormalizeForLoopInitDeclaration
[[visibility("default")]] 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
[[visibility("default")]] void updateDefiningNondefiningLinks( SgFunctionDeclaration* func, SgScopeStatement* scope);
Validate a published function's canonical symbol and link its exact declaration family when the new function is a definition.
usualArithmeticConversionType
[[visibility("default")]] 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
[[visibility("default")]] 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

Created with MrDocs