Skip to content

ASTtools

Types

Name

Description

PrePostTraversal

JumpMap_t

Store a list of non‐local "jumps" (continues, breaks) and ids.

ThisExprSet_t

Stores a list of 'this' expressions.

VarSymSet_t

Stores a collection of SgVariableSymbols (var syms).

Functions

Name

Description

appendCopy
void appendCopy(SgStatement const* s, SgBasicBlock* b);

Append a deep‐copy of statement s onto the basic block b.

appendStmtsCopy
void appendStmtsCopy(SgBasicBlock const* a, SgBasicBlock* b);

Append a deep‐copy of statements from a to the basic block b.

attachComment
void attachComment(std::string const& comment, SgStatement* s);

Attaches a string as a new C++‐style comment to the given statement.

collectDefdVarSyms
void collectDefdVarSyms(SgStatement const* s, VarSymSet_t& syms);

Collect var syms for all local variable declarations at 's'.

collectLocalVisibleVarSyms
void collectLocalVisibleVarSyms(SgStatement const* root, SgStatement const* target, VarSymSet_t& syms);

Collect var syms declared at 'root' or below that are visible to 'target'.

collectNonLocalGotos
void collectNonLocalGotos(SgStatement const* root, JumpMap_t& jumps);

Collect non‐local "goto" statements.

collectNonLocalJumps
void collectNonLocalJumps(SgStatement const* root, JumpMap_t& jumps);

Collect non‐local "jumps" within a statement.

collectPointerDereferencingVarSyms
void collectPointerDereferencingVarSyms(SgStatement const* s, VarSymSet_t& pdSyms);

Collect variables suitable for using pointer dereferencing

collectRefdVarSyms
void collectRefdVarSyms(SgStatement const* s, VarSymSet_t& syms);

Collect var syms for all variable references at 's'.

collectThisExpressions
void collectThisExpressions(SgStatement const* root, ThisExprSet_t& exprs);

Collect 'this' expressions.

collectVarRefsOfTypeWithoutAssignmentSupport
void collectVarRefsOfTypeWithoutAssignmentSupport(SgStatement const* s, std::set<SgVarRefExp*>& varSetB);

Collect variable references with a type which does not support =operator or copy construction. Those two support is essential for temp variables used to copy and restore parameters

collectVarRefsUsingAddress
void collectVarRefsUsingAddress(SgStatement const* s, std::set<SgVarRefExp*>& varSetB);

Collect variable references using addresses for s

createInfoList
AttachedPreprocessingInfoType* createInfoList(SgStatement* s);

Returns the preprocessing information list attached to the given statement; if no preprocessing information exists, then this routine will create an empty list and return its pointer. Thus, this routine is guaranteed to return a non‐NULL result.

cutPreprocInfo
void cutPreprocInfo(SgBasicBlock* b, PreprocessingInfo::RelativePositionType pos, AttachedPreprocessingInfoType& save_buf);

Removes all preprocessing information at a given position.

deepCopy
SgNode* deepCopy(SgNode const* n);

Create a deep‐copy of an SgNode

dumpPreprocInfo
void dumpPreprocInfo(SgStatement const* s, std::ostream& o);

Dumps a statement's preprocessing information.

dumpSymTab
void dumpSymTab(SgScopeStatement const* s, std::string const& tag, std::ostream& o);

Dump a symbol table.

findFirstFuncDef
SgFunctionDefinition const* findFirstFuncDef(SgStatement const* s);

Search for the first surrounding function definition.

findFirstFuncDefScope
SgScopeStatement const* findFirstFuncDefScope(SgStatement const* s);

Search for the first surrounding scope that may contain a function def.

getClassName
std::string getClassName(SgMemberFunctionDeclaration const* mem_func);

Returns the name of the class of a member function.

getMemFuncName
std::string getMemFuncName(SgMemberFunctionDeclaration const* mem_func);

Returns the unqualified name of the member function.

getNumArgs
size_t getNumArgs(SgFunctionDeclaration const* func);

Returns the number of function arguments, including 'this' for member functions.

getUnqualUntmplName
std::string getUnqualUntmplName(SgDeclarationStatement const* d);

Returns a non‐templated, unqualified name.

insertHeader
bool insertHeader(std::string const& filename, SgProject* proj);

Inserts an '#include' of a header file at the first statement.

isC99
bool isC99(SgNode const* n);

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

isConstMemFunc
bool isConstMemFunc(SgFunctionDeclaration const* decl);

Returns 'true' if the specific function is a 'const' member function.

isConstObj
bool isConstObj(SgType const* type);

Returns 'true' if the specified type is a 'const' object.

isCtor
bool isCtor(SgFunctionDeclaration const* func);

Returns true if 'func' is a constructor.

isDtor
bool isDtor(SgFunctionDeclaration const* func);

Returns true if 'func' is a destructor.

isExternC
bool isExternC(SgFunctionDeclaration const* func);

Returns 'true' iff the given function is declared 'extern "C"'.

isFuncName
bool isFuncName(SgFunctionDeclaration const* func, std::string const& target);

Returns true iff the function's unqualified name equals the target name.

isFuncNamePrefix
bool isFuncNamePrefix(SgFunctionDeclaration const* func, std::string const& target_prefix);

Returns true iff the function's unqualified name begins with the target prefix.

isIfCond
bool isIfCond(SgStatement const* s);

Returns 'true' <==> 's' is the condition of some 'if' statement.

isIfDirectiveBegin
bool isIfDirectiveBegin(PreprocessingInfo const* info);

Returns true if the info is an '#if', '#ifdef', or '#ifndef'.

isIfDirectiveEnd
bool isIfDirectiveEnd(PreprocessingInfo const* info);

isIfDirectiveMiddle
bool isIfDirectiveMiddle(PreprocessingInfo const* info);

Returns true if the info is an '#elif' or '#else'.

isMain
bool isMain(SgFunctionDeclaration const* decl);

Returns 'true' if the function is 'main'.

isPositionAfter
bool isPositionAfter(PreprocessingInfo const* info);

Returns true if info is positioned after its statement.

isPositionBefore
bool isPositionBefore(PreprocessingInfo const* info);

Returns true if info is positioned before its statement.

isPositionInside
bool isPositionInside(PreprocessingInfo const* info);

Returns true if info is positioned inside its statement.

isStaticFunc
bool isStaticFunc(SgFunctionDeclaration const* func);

Returns true iff the given function declaration is 'static'.

isStdNamespace
bool isStdNamespace(SgScopeStatement const* scope);

Returns 'true' if the scope is the '::std' namespace.

isSwitchCond
bool isSwitchCond(SgStatement const* s);

Returns 'true' <==> 's' is the conditional selector of some 'switch' statement.

isTemplateInst
bool isTemplateInst(SgDeclarationStatement const* decl);

isTemplateInst overloads

isWhileCond
bool isWhileCond(SgStatement const* s);

Returns 'true' <==> 's' is the condition of some 'while' or 'do ... while' statement.

moveAfterPreprocInfo
void moveAfterPreprocInfo(SgStatement* src, SgStatement* dest);

Moves 'after' preprocessing information.

moveBeforePreprocInfo
void moveBeforePreprocInfo(SgStatement* src, SgStatement* dest);

Moves 'before' preprocessing information.

moveInsidePreprocInfo
void moveInsidePreprocInfo(SgBasicBlock* src, SgBasicBlock* dest);

Moves 'inside' preprocessing information.

moveStatements
void moveStatements(SgBasicBlock* src, SgBasicBlock* target);

Move statements from one basic‐block to another.

moveUpPreprocInfo
void moveUpPreprocInfo(SgStatement* stmt1, SgStatement* stmt2);

Moves preprocessingInfo of stmt2 to stmt1.

newFileInfo
Sg_File_Info* newFileInfo();

Returns a newly allocated file info object for transformation nodes.

pastePreprocInfoBack
void pastePreprocInfoBack(AttachedPreprocessingInfoType& save_buf, SgStatement* s);

Pastes preprocessing information at the back of a statement.

pastePreprocInfoFront
void pastePreprocInfoFront(AttachedPreprocessingInfoType& save_buf, SgStatement* s);

Pastes preprocessing information at the front of a statement.

replaceStatement
void replaceStatement(SgStatement* s_cur, SgStatement* s_new);

Replaces one statement with another.

setSourcePositionAsTransformation
void setSourcePositionAsTransformation(SgNode* node);

Reset source position as transformation for the current node only

setSourcePositionAtRootAndAllChildrenAsTransformation
void setSourcePositionAtRootAndAllChildrenAsTransformation(SgNode* node);

Reset source position as transformation recursively

toString
std::string toString(VarSymSet_t const& syms);

Convert a variable symbol set to a string‐friendly form for debugging.

toStringFileLoc
std::string toStringFileLoc(SgLocatedNode const* n);

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

transformToBlockShell
SgBasicBlock* transformToBlockShell(SgBasicBlock* b_orig);

Create an SgBasicBlock shell around an existing SgBasicBlock.

Created with MrDocs