1 #ifndef ROSE_SAGE_INTERFACE
2 #define ROSE_SAGE_INTERFACE
4 #include "sage3basic.hhh"
8 #include "rosePublicConfig.h"
10 #if 0 // FMZ(07/07/2010): the argument "nextErrorCode" should be call-by-reference
11 SgFile* determineFileType ( std::vector<std::string> argv,
int nextErrorCode,
SgProject* project );
13 SgFile* determineFileType ( std::vector<std::string> argv,
int& nextErrorCode,
SgProject* project );
16 #ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
21 #include "astUnparseAttribute.h"
24 #ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
25 #include "LivenessAnalysis.h"
26 #include "abstract_handle.h"
27 #include "ClassHierarchyGraph.h"
30 #include "ompSupport.h"
33 ROSE_DLL_API std::string getVariantName (VariantT v);
55 #define TRANS_FILE Sg_File_Info::generateDefaultFileInfoForTransformationNode()
69 std::map <SgForStatement* , bool > forLoopInitNormalizationTable;
71 std::map <SgForStatement* , std::pair<SgVariableDeclaration*, SgVariableDeclaration*> > forLoopInitNormalizationRecord;
88 std::map<SgDeclarationStatement*,std::set<SgDeclarationStatement*>* > declarationMap;
94 std::map<SgDeclarationStatement*,std::set<SgDeclarationStatement*>* > & getDeclarationMap();
118 void set_name (std::string n) {name = n;};
119 std::string get_name () {
return name;};
456 std::string
generateUniqueName (
const SgNode * node,
bool ignoreDifferenceBetweenDefiningAndNondefiningDeclarations);
522 template <
typename NodeType>
568 std::vector<SgInitializedName*>
getInParameters(
const SgInitializedNamePtrList ¶ms);
571 std::vector<SgInitializedName*>
getOutParameters(
const SgInitializedNamePtrList ¶ms);
599 ROSE_DLL_API std::vector<SgDeclarationStatement*>
643 #define INLINE_OPTIMIZED_IS_LANGUAGE_KIND_FUNCTIONS 1
648 #if INLINE_OPTIMIZED_IS_LANGUAGE_KIND_FUNCTIONS
762 const std::string & text,
772 const std::string & content,
773 PreprocessingInfo::DirectiveType directive_type = PreprocessingInfo::C_StyleComment,
780 PreprocessingInfo::DirectiveType dtype= PreprocessingInfo::CpreprocessorUnknownDeclaration);
784 ROSE_DLL_API
void addTextForUnparser (
SgNode* astNode, std::string s, AstUnparseAttribute::RelativePositionType inputlocation );
884 #ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
978 std::vector<SgExpression*>
1001 std::vector<SgExpression*>
1007 std::vector<SgExpression*>
1206 template <
typename NodeType>
1211 printf (
"Top of SageInterface::querySubTree() \n");
1214 Rose_STL_Container<SgNode*> nodes = NodeQuery::querySubTree(top,variant);
1215 std::vector<NodeType*> result(nodes.size(), NULL);
1218 printf (
"In SageInterface::querySubTree(): before initialization loop \n");
1221 for (Rose_STL_Container<SgNode*>::const_iterator i = nodes.begin(); i != nodes.end(); ++i, ++count)
1224 printf (
"In SageInterface::querySubTree(): in loop: count = %d \n",count);
1226 NodeType* node =
dynamic_cast<NodeType*
>(*i);
1228 result[count] = node;
1231 printf (
"Leaving SageInterface::querySubTree(): after initialization loop \n");
1252 template <
typename NodeType>
1253 static std::vector<NodeType*> getSgNodeListFromMemoryPool()
1259 std::vector<NodeType*> resultlist;
1260 void visit (
SgNode* node)
1262 NodeType* result =
dynamic_cast<NodeType*
> (node);
1263 ROSE_ASSERT(result!= NULL);
1266 resultlist.push_back(result);
1269 virtual ~MyTraversal() {}
1272 MyTraversal my_traversal;
1273 NodeType::traverseMemoryPoolNodes(my_traversal);
1274 return my_traversal.resultlist;
1311 template <
typename T>
1317 printf (
"In findDeclarationStatement(): root = %p \n",root);
1318 printf (
"In findDeclarationStatement(): name = %s \n",name.c_str());
1319 printf (
"In findDeclarationStatement(): scope = %p \n",scope);
1320 printf (
"In findDeclarationStatement(): isDefining = %s \n",isDefining ?
"true" :
"false");
1325 if (!root)
return NULL;
1327 T* decl =
dynamic_cast<T*
>(root);
1330 printf (
"In findDeclarationStatement(): decl = %p \n",decl);
1337 if ((decl->get_scope() == scope) && (decl->search_for_symbol_from_symbol_table()->get_name() == name))
1346 SgSymbol* symbol = decl->search_for_symbol_from_symbol_table();
1347 printf (
"In findDeclarationStatement(): decl->search_for_symbol_from_symbol_table() = %p \n",symbol);
1348 printf (
"In findDeclarationStatement(): decl->search_for_symbol_from_symbol_table()->get_name() = %s \n",symbol->
get_name().str());
1350 if (decl->search_for_symbol_from_symbol_table()->get_name() == name)
1362 printf (
"In findDeclarationStatement(): decl->get_firstNondefiningDeclaration() = %p \n",decl->get_firstNondefiningDeclaration());
1363 printf (
"In findDeclarationStatement(): decl->get_definingDeclaration() = %p \n",decl->get_definingDeclaration());
1365 ROSE_ASSERT (decl->get_definingDeclaration() != NULL);
1367 printf (
"In findDeclarationStatement(): returing decl->get_definingDeclaration() = %p \n",decl->get_definingDeclaration());
1369 return dynamic_cast<T*
> (decl->get_definingDeclaration());
1374 printf (
"In findDeclarationStatement(): returing decl = %p \n",decl);
1383 printf (
"In findDeclarationStatement(): children.size() = %zu \n",children.size());
1388 for (std::vector<SgNode*>::const_iterator i = children.begin(); i != children.end(); ++i)
1390 T* target = findDeclarationStatement<T> (*i,name,scope,isDefining);
1406 SgNode* getNextSgNode(
const SgNode* astSourceNode, VariantT=V_SgNode,
SgNode* astEndNode=NULL);
1409 std::vector<SgNode*> getAllNextSgNode(
const SgNode* astSourceNode, VariantT=V_SgNode,
SgNode* astEndNode=NULL);
1436 template <
typename NodeType>
1439 #define DEBUG_GET_ENCLOSING_NODE 0
1449 if (
nullptr == astNode)
1454 if ( (includingSelf ) && (
dynamic_cast<const NodeType*
>(astNode)) )
1456 return const_cast<NodeType*
>(
dynamic_cast<const NodeType*
> (astNode));
1460 ROSE_ASSERT(astNode->
get_parent() != astNode);
1465 SgNode* previouslySeenParent = parent;
1466 bool foundCycle =
false;
1469 #if DEBUG_GET_ENCLOSING_NODE
1470 printf (
"In getEnclosingNode(): previouslySeenParent = %p = %s \n",previouslySeenParent,previouslySeenParent->
class_name().c_str());
1473 while ( (foundCycle ==
false) && (parent !=
nullptr) && (!
dynamic_cast<const NodeType*
>(parent)) )
1477 #if DEBUG_GET_ENCLOSING_NODE
1478 printf (
" --- parent = %p = %s \n",parent,parent->
class_name().c_str());
1489 if (counter >= 100000)
1491 printf (
"Exiting: In getEnclosingNode(): loop limit exceeded: counter = %d \n",counter);
1499 if (parent == previouslySeenParent)
1507 #if DEBUG_GET_ENCLOSING_NODE
1508 printf (
"previouslySeenParent = %p = %s \n",previouslySeenParent,previouslySeenParent->
class_name().c_str());
1511 parent = previouslySeenParent;
1514 if (declarationStatement !=
nullptr)
1517 printf (
"Found a SgDeclarationStatement \n");
1523 printf (
" --- declarationStatement = %p \n",declarationStatement);
1524 printf (
" --- definingDeclaration = %p \n",definingDeclaration);
1525 if (definingDeclaration != NULL && definingDeclaration->
get_parent() != NULL)
1526 printf (
" --- definingDeclaration ->get_parent() = %p = %s \n",definingDeclaration->
get_parent(),definingDeclaration->
get_parent()->
class_name().c_str());
1527 printf (
" --- firstNondefiningDeclaration = %p \n",firstNondefiningDeclaration);
1528 if (firstNondefiningDeclaration != NULL && firstNondefiningDeclaration->
get_parent() != NULL)
1529 printf (
" --- firstNondefiningDeclaration ->get_parent() = %p = %s \n",firstNondefiningDeclaration->
get_parent(),firstNondefiningDeclaration->
get_parent()->
class_name().c_str());
1531 if (definingDeclaration !=
nullptr && declarationStatement != firstNondefiningDeclaration)
1534 printf (
"Found a nondefining declaration so use the non-defining declaration instead \n");
1538 parent = definingDeclaration;
1543 printf (
"reset: previouslySeenParent = %p = %s \n",previouslySeenParent,previouslySeenParent->
class_name().c_str());
1557 if (foundCycle ==
false)
1561 while ( (parent !=
nullptr) && (!
dynamic_cast<const NodeType*
>(parent)) )
1565 printf (
"In getEnclosingNode() (2nd try): parent = %p = %s \n",parent,parent->
class_name().c_str());
1567 parent->
get_file_info()->display(
"In getEnclosingNode() (2nd try): debug");
1570 if (declarationStatement !=
nullptr)
1572 #if DEBUG_GET_ENCLOSING_NODE
1573 printf (
"Found a SgDeclarationStatement \n");
1577 if (definingDeclaration !=
nullptr && declarationStatement != firstNondefiningDeclaration)
1580 printf (
"Found a nondefining declaration so use the firstNondefining declaration instead \n");
1584 parent = definingDeclaration;
1592 ROSE_ASSERT(parent != previouslySeenParent);
1594 printf (
"WARNING::WARNING::WARNING commented out assertion for parent != previouslySeenParent \n");
1595 if (parent == previouslySeenParent)
1601 return const_cast<NodeType*
>(
dynamic_cast<const NodeType*
> (parent));
1608 std::set<const SgNode*> seen;
1610 if (NodeType *found =
dynamic_cast<NodeType*
>(node))
1615 if (seen.insert(node).second ==
false)
1617 printf (
"Error: node is already in set and defines a cycle: node = %p = %s \n",node,node->
class_name().c_str());
1618 std::set<const SgNode*>::const_iterator i = seen.begin();
1619 while (i != seen.end())
1621 const SgNode* element = *i;
1622 printf (
" --- seen element: element = %p = %s \n",element,element->
class_name().c_str());
1626 printf (
"Exiting after error! \n");
1635 if (definingDeclaration && firstNondefiningDeclaration && declarationStatement != firstNondefiningDeclaration) {
1638 node = definingDeclaration;
1732 std::vector<SgNode *> getAllEnclosingSgNode(
SgNode* source,VariantT,
SgNode* endNode=NULL);
1776 SgNode* getNextSgNode(
const SgNode* currentNode, VariantT=V_SgNode);
1826 enum TransformationKind
1835 e_replaceDefiningFunctionDeclarationWithFunctionPrototype,
1839 TransformationKind deferredTransformationKind;
1844 std::string transformationLabel;
1854 typedef std::set<SgClassDefinition *> ClassDefSet_t;
1855 ClassDefSet_t targetClasses;
1857 typedef std::vector<SgFunctionDeclaration *> FuncDeclList_t;
1858 FuncDeclList_t targetFriends;
1866 typedef std::vector<SgStatement*> IntervalType;
1867 IntervalType statementInterval;
1868 SgStatement* locationToOverwriteWithTransformation;
1869 SgStatement* transformationToOverwriteFirstStatementInInterval;
1884 static ROSE_DLL_API std::string outputDeferredTransformationKind(
const TransformationKind & kind);
1885 ROSE_DLL_API
void display ( std::string label )
const;
2043 template <
class actualFunction>
2053 ROSE_ASSERT(func != NULL);
2054 ROSE_ASSERT(paralist != NULL);
2061 cerr <<
"Waring! Setting a used SgFunctionParameterList to function: "
2062 << (func->get_name()).getString()<<endl
2063 <<
" Sharing parameter lists can corrupt symbol tables!"<<endl
2064 <<
" Please use deepCopy() to get an exclusive parameter list for each function declaration!"<<endl;
2070 if (func->get_parameterList() != NULL)
2072 if (func->get_parameterList() != paralist)
2074 delete func->get_parameterList();
2078 func->set_parameterList(paralist);
2085 SgInitializedNamePtrList & args = paralist->
get_args();
2086 for (SgInitializedNamePtrList::iterator i = args.begin(); i != args.end(); i++)
2088 (*i)->set_declptr(func);
2288 #ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
2293 ROSE_DLL_API
void getLiveVariables(LivenessAnalysis * liv,
SgForStatement* loop, std::set<SgInitializedName*>& liveIns, std::set<SgInitializedName*> & liveOuts);
2473 std::pair<SgStatement*, SgInitializedName*>
2481 template <
class NameGen>
2482 std::pair<SgStatement*, SgInitializedName*>
2485 return wrapFunction(definingDeclaration, nameGen(definingDeclaration.get_name()));
2502 std::string buildOperatorString (
SgNode* astNode );
2505 std::string dump_node(
const SgNode* astNode);
2506 std::string dump_tree(
const SgNode* astNode);
2509 std::string SgNode::toString(
bool asSubTree=
true);
2520 bool expressionTreeEqualStar(
const SgExpressionPtrList&,
2521 const SgExpressionPtrList&);
2527 verifySgNode(
SgNode* node,
bool subTree=
true);
2544 void insertAst(
SgNode* targetPosition,
SgNode* newNode,
bool insertBefore=
true);
2556 void removeSgNode(
SgNode* targetNode);
2557 void removeSgNodeTree(
SgNode* subtree);
2580 void flattenBlocks(
SgNode* n);
2583 void renameVariables(
SgNode* n);
2586 void simpleCopyAndConstantPropagation(
SgNode* top);
2587 void changeAllMembersToPublic(
SgNode* n);
2598 void pushTestIntoBody(LoopStatement* loopStmt);
2602 void moveForDeclaredVariables(
SgNode* root);
2628 bool isConst(
SgNode* node);
2651 bool isPotentiallyModifiedDuringLifeOf(
SgBasicBlock* sc,
2655 bool anyOfListPotentiallyModifiedIn(
const std::vector<SgVariableSymbol*>& syms,
SgNode* n);
2674 void replaceAssignmentStmtWithStatement(
SgExprStatement* from, StatementGenerator* to);
2677 StatementGenerator* to);
2685 AttachedPreprocessingInfoType& save_buf);
2687 void pastePreprocInfoFront (AttachedPreprocessingInfoType& save_buf,
2690 void pastePreprocInfoBack (AttachedPreprocessingInfoType& save_buf,
2706 from transformationSupport.h, not sure
if they should be included here
2708 operatorCodeType classifyOverloadedOperator();
2715 std::string stringifyOperator (std::string name);
2719 std::string buildMacro ( std::string s );
2724 * get/set a direct child/grandchild node or fields
2725 * get/set a
property flag value
2726 * get a descendent child node
using preorder searching
2727 * get an
ancestor node
using bottomup/reverse searching
2803 template <
class T >
2815 bool retval =
false;
2817 #define DEBUG_TEMPLATE_NORMALIZATION_DETECTION 0
2819 #if DEBUG_TEMPLATE_NORMALIZATION_DETECTION
2820 printf (
"In isNormalizedTemplateInstantiation(): function = %p = %s = %s \n",
function,function->class_name().c_str(),function->get_name().str());
2829 if (templateInstantiationFunction != NULL)
2834 if (templateFunctionDeclaration != NULL)
2836 retval = filter->operator()(templateFunctionDeclaration);
2843 #if DEBUG_TEMPLATE_NORMALIZATION_DETECTION
2844 printf (
" --- case of templateInstantiationFunction: retval = %s \n",retval ?
"true" :
"false");
2849 if (templateInstantiationMemberFunction != NULL)
2852 templateInstantiationMemberFunction = isSgTemplateInstantiationMemberFunctionDecl(templateInstantiationMemberFunction->
get_firstNondefiningDeclaration());
2854 if (templateMemberFunctionDeclaration != NULL)
2856 retval = filter->operator()(templateMemberFunctionDeclaration);
2863 #if DEBUG_TEMPLATE_NORMALIZATION_DETECTION
2864 printf (
" --- case of templateInstantiationMemberFunction: retval = %s \n",retval ?
"true" :
"false");
ROSE_DLL_API SgFunctionDeclaration * getFunctionDeclaration(SgFunctionCallExp *functionCallExp)
Find a node by type using upward traversal.
ROSE_DLL_API bool isConstType(SgType *t)
Is this a const type?
ROSE_DLL_API bool is_C99_language()
PreprocessingInfo * attachComment(SgSourceFile *source_file, const std::string &content, PreprocessingInfo::DirectiveType directive_type=PreprocessingInfo::C_StyleComment, PreprocessingInfo::RelativePositionType position=PreprocessingInfo::before)
Build and attach comment onto the global scope of a source file.
ROSE_DLL_API bool templateDefinitionIsInClass(SgTemplateInstantiationMemberFunctionDecl *memberFunctionDeclaration)
Return true if template definition is in the class, false if outside of class.
ROSE_DLL_API 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.
This class represents the notion of an expression or statement which has a position within the source...
ROSE_DLL_API SgClassDeclaration * getEnclosingClassDeclaration(SgNode *astNode)
Get the closest class declaration enclosing the specified AST node,.
ROSE_DLL_API SgFunctionSymbol * lookupTemplateFunctionSymbolInParentScopes(const SgName &functionName, SgFunctionType *ftype, SgTemplateParameterPtrList *tplparams, SgScopeStatement *currentScope=NULL)
Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeSta...
std::string addMangledNameToCache(SgNode *astNode, const std::string &mangledName)
Recursively print current and parent nodes. used within gdb to probe the context of a node.
void listHeaderFiles(SgIncludeFile *includeFile)
return path prefix for subtree of include files.
struct const_int_expr_t evaluateConstIntegerExpression(SgExpression *expr)
The function tries to evaluate const integer expressions (such as are used in array dimension sizes)....
ROSE_DLL_API bool isAddressTaken(SgExpression *refExp)
Find a node by type using upward traversal.
ROSE_DLL_API bool is_Cuda_language()
ROSE_DLL_API SgExpression * copyExpression(SgExpression *e)
Deep copy an expression.
ROSE_DLL_API std::string mangleScalarType(SgType *type)
Generate mangled scalar type names according to Itanium C++ ABI, the input type should pass isScalarT...
std::string generateUniqueName(const SgNode *node, bool ignoreDifferenceBetweenDefiningAndNondefiningDeclarations)
Generate unique name from C and C++ constructs. The name may contain space.
void reset_name_collision_map()
Reset map variables used to support generateUniqueNameForUseAsIdentifier() function.
ROSE_DLL_API void insertStatementListBeforeFirstNonDeclaration(const std::vector< SgStatement * > &newStmts, SgScopeStatement *scope)
Insert statements before the first non-declaration statement in a scope. If the scope has no non-decl...
ROSE_DLL_API void translateToUseCppDeclarations(SgNode *n)
Connect variable reference to the right variable symbols when feasible, return the number of referenc...
void printAST(SgNode *node)
Pretty print AST horizontally, output to std output.
ROSE_DLL_API void constantFolding(SgNode *r)
Constant folding an AST subtree rooted at 'r' (replacing its children with their constant values,...
ROSE_DLL_API void removeLabeledGotos(SgNode *top)
Remove labeled goto statements.
ROSE_DLL_API 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 su...
This class represents the concept of a variable name within the compiler (a shared container for the ...
bool HasNoThrowConstructor(const SgType *const inputType)
Collect all read and write references within stmt, which can be a function, a scope statement,...
ROSE_DLL_API bool isInSubTree(SgExpression *subtree, SgExpression *exp)
Find a node by type using upward traversal.
ROSE_DLL_API bool isEquivalentType(const SgType *lhs, const SgType *rhs)
Test for equivalence of types independent of access permissions (private or protected modes for membe...
virtual Sg_File_Info * get_file_info(void) const
File information containing filename, line number, column number, and if the SgNode is a part of a ne...
void fixupReferencesToSymbols(const SgScopeStatement *this_scope, SgScopeStatement *copy_scope, SgCopyHelp &help)
All the symbol table references in the copied AST need to be reset after rebuilding the copied scope'...
ROSE_DLL_API bool isOmpStatement(SgNode *)
Check if a node is SgOmp*Statement.
SgExprListExp * loopCollapsing(SgForStatement *target_loop, size_t collapsing_factor)
Add a step statement to the end of a loop body Add a new label to the end of the loop,...
ROSE_DLL_API SgVariableSymbol * getFirstVarSym(SgVariableDeclaration *decl)
Get the variable symbol for the first initialized name of a declaration stmt.
ROSE_DLL_API void setPragma(SgPragmaDeclaration *decl, SgPragma *pragma)
Set a pragma of a pragma declaration. handle memory release for preexisting pragma,...
ROSE_DLL_API SgStatement * getEnclosingStatement(SgNode *n)
Find the closest enclosing statement, including the given node.
ROSE_DLL_API bool is_mixed_Fortran_and_C_and_Cxx_language()
NodeType * deepCopy(const NodeType *subtree)
A template function for deep copying a subtree. It is also used to create deepcopy functions with spe...
ROSE_DLL_API SgVariableSymbol * prependArg(SgFunctionParameterList *, SgInitializedName *)
Prepend an argument to SgFunctionParameterList.
ROSE_DLL_API void insertStatementList(SgStatement *targetStmt, const std::vector< SgStatement * > &newStmts, bool insertBefore=true)
Insert a list of statements before or after the target statement within the.
ROSE_DLL_API std::string generateProjectName(const SgProject *project, bool supressSuffix=false)
Added mechanism to generate project name from list of file names.
ROSE_DLL_API 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 tru...
std::pair< SgVariableDeclaration *, SgExpression * > createTempVariableAndReferenceForExpression(SgExpression *expression, SgScopeStatement *scope)
Function to delete AST subtree's nodes only, users must take care of any dangling pointers,...
ROSE_DLL_API 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-dec...
This class represents the concept of a C++ namespace declaration.
ROSE_DLL_API bool hasMultipleInitStatmentsOrExpressions(SgForStatement *for_loop)
Check if a for loop uses C99 style initialization statement with multiple expressions like for (int i...
ROSE_DLL_API bool mergeDeclarationAndAssignment(SgVariableDeclaration *decl, SgExprStatement *assign_stmt, bool removeAssignStmt=true)
Merge a variable assignment statement into a matching variable declaration statement....
This class represents a type for all functions.
ROSE_DLL_API void insertStatementBefore(SgStatement *targetStmt, SgStatement *newStmt, bool autoMovePreprocessingInfo=true)
Insert a statement before a target statement.
ROSE_DLL_API bool hasTrivialDestructor(SgType *t)
Does a type have a trivial (built-in) destructor?
ROSE_DLL_API SgFunctionDefinition * getEnclosingFunctionDefinition(SgNode *astNode, const bool includingSelf=false)
Find a node by type using upward traversal.
SgType * removeConst(SgType *t)
Remove const (if present) from a type. stripType() cannot do this because it removes all modifiers.
ROSE_DLL_API 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,...
This class represents the concept of a C and C++ case option (used within a switch statement).
void printAST2TextFile(SgNode *node, const char *filename, bool printType=true)
Pretty print AST horizontally, output to a specified text file. If printType is set to false,...
ROSE_DLL_API void dumpInfo(SgNode *node, std::string desc="")
Dump information about a SgNode for debugging.
ROSE_DLL_API void insertStatementListBefore(SgStatement *targetStmt, const std::vector< SgStatement * > &newStmts)
Insert a list of statements before a target statement.
ROSE_DLL_API void addTextForUnparser(SgNode *astNode, std::string s, AstUnparseAttribute::RelativePositionType inputlocation)
Add a string to be unparsed to support code generation for back-end specific tools or compilers.
ROSE_DLL_API SgNode * deepCopyNode(const SgNode *subtree)
Deep copy an arbitrary subtree.
void clearScopeNumbers(SgFunctionDefinition *functionDefinition)
Clears the cache of scope,integer pairs for the input function.
ROSE_DLL_API void outputLocalSymbolTables(SgNode *node)
Output the local symbol tables.
ROSE_DLL_API SgType * getArrayElementType(SgType *t)
Get the element type of an array. It recursively find the base type for multi-dimension array types.
bool HasVirtualDestructor(const SgType *const inputType)
Collect all read and write references within stmt, which can be a function, a scope statement,...
ROSE_DLL_API bool isUpcStrictSharedModifierType(SgModifierType *mode_type)
Check if a shared UPC type is strict memory consistency or not. Return false if it is relaxed....
bool HasTrivialCopy(const SgType *const inputType)
Collect all read and write references within stmt, which can be a function, a scope statement,...
ROSE_DLL_API 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,...
ROSE_DLL_API bool isUpcPhaseLessSharedType(SgType *t)
Is UPC phase-less shared type? Phase-less means block size of the first SgModifierType with UPC infor...
This class represents the concept of an "if" construct.
ROSE_DLL_API void moveToSubdirectory(std::string directoryName, SgFile *file)
Move file to be generated in a subdirectory (will be generated by the unparser).
ROSE_DLL_API void printOutComments(SgLocatedNode *locatedNode)
Connect variable reference to the right variable symbols when feasible, return the number of referenc...
bool HasTrivialAssign(const SgType *const inputType)
Collect all read and write references within stmt, which can be a function, a scope statement,...
ROSE_DLL_API SgFunctionDeclaration * findFirstDefiningFunctionDecl(SgScopeStatement *scope)
Find the first defining function declaration statement in a scope.
This class represents the concept of a class definition in C++.
ROSE_DLL_API void setLhsOperand(SgExpression *target, SgExpression *lhs)
set left hand operand for binary expressions, transparently downcasting target expressions when neces...
ROSE_DLL_API SgTemplateClassSymbol * lookupTemplateClassSymbolInParentScopes(const SgName &name, SgTemplateParameterPtrList *templateParameterList, SgTemplateArgumentPtrList *templateArgumentList, SgScopeStatement *cscope=NULL)
Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeSta...
void setSourcePositionPointersToNull(SgNode *node)
Set the source code positon for the current (input) node.
ROSE_DLL_API void setSourcePositionAtRootAndAllChildren(SgNode *root)
Set the source code positon for the subtree (including the root).
This class represents the concept of a C or C++ default case within a switch statement.
ROSE_DLL_API void fixStatement(SgStatement *stmt, SgScopeStatement *scope)
A wrapper containing fixes (fixVariableDeclaration(),fixStructDeclaration(), fixLabelStatement(),...
void initializeIfStmt(SgIfStmt *ifstmt, SgStatement *conditional, SgStatement *true_body, SgStatement *false_body)
Support function used for variable declarations in conditionals.
This class represents the concept of a namespace definition.
ROSE_DLL_API void resetModifiedLocatedNodes(const std::set< SgLocatedNode * > &modifiedNodeSet)
Use the set of IR nodes and set the isModified flag in each IR node to true.
This class represents the concept of a do-while statement.
std::string extractPragmaKeyword(const SgPragmaDeclaration *)
Extract a SgPragmaDeclaration's leading keyword . For example "#pragma omp parallel" has a keyword of...
ROSE_DLL_API void deleteExpressionTreeWithOriginalExpressionSubtrees(SgNode *root)
Special purpose function for deleting AST expression tress containing valid original expression trees...
ROSE_DLL_API void insertStatementAfter(SgStatement *targetStmt, SgStatement *newStmt, bool autoMovePreprocessingInfo=true)
Insert a statement after a target statement, Move around preprocessing info automatically by default.
ROSE_DLL_API void insertStatementListAfter(SgStatement *targetStmt, const std::vector< SgStatement * > &newStmt)
Insert a list of statements after a target statement.
bool HasTrivialDestructor(const SgType *const inputType)
Collect all read and write references within stmt, which can be a function, a scope statement,...
ROSE_DLL_API SgBasicBlock * ensureBasicBlockAsBodyOfSwitch(SgSwitchStatement *ws)
Check if the body of a 'switch' statement is a SgBasicBlock, create one if not.
bool isTemplateInstantiationFromTemplateDeclarationSatisfyingFilter(SgFunctionDeclaration *function, T *filter)
This function detects template instantiations that are relevant when filters are used.
ROSE_DLL_API void removeUnusedLabels(SgNode *top, bool keepChild=false)
Remove labels which are not targets of any goto statements: its child statement is also removed by de...
ROSE_DLL_API void setSourcePositionForTransformation(SgNode *root)
Recursively set source position info(Sg_File_Info) as transformation generated.
std::string generateUniqueNameForUseAsIdentifier_support(SgDeclarationStatement *declaration)
Global map of name collisions to support generateUniqueNameForUseAsIdentifier() function.
This class represents the concept of a class declaration statement. It includes the concept of an ins...
This class represents the concept of a for loop.
bool isOverloaded(SgFunctionDeclaration *functionDeclaration)
Return true if function is overloaded.
ROSE_DLL_API 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 pa...
void guardNode(SgLocatedNode *target, std::string guard)
Add preproccessor guard around a given node.
ROSE_DLL_API bool isCopyConstructible(SgType *type)
Is a type copy constructible? This may not quite work properly.
ROSE_DLL_API bool isStructType(SgType *t)
Check if a type is a struct type (a special SgClassType in ROSE). Typedef and modifier types are not ...
bool isPrefixOperator(SgExpression *exp)
Is an overloaded operator a prefix operator (e.g. address operator X * operator&(),...
ROSE_DLL_API SgBasicBlock * ensureBasicBlockAsBodyOfOmpBodyStmt(SgUpirBodyStatement *ompbodyStmt)
Check if the body of a SgUpirBodyStatement is a SgBasicBlock, create one if not.
Base class for all IR node attribute values.
ROSE_DLL_API bool isUpcSharedModifierType(SgModifierType *mod_type)
Check if a modifier type is a UPC shared type.
unsigned long long getIntegerConstantValue(SgValueExp *expr)
Get the constant value from a constant integer expression; abort on everything else.
SgType * getDeclaredType(const SgDeclarationStatement *declaration)
Returns the type introduced by a declaration.
ROSE_DLL_API bool isConstantTrue(SgExpression *e)
Check if a bool or int constant expression evaluates to be a true value.
This class represents the variable refernece in expressions.
This class represents the rhs of a variable declaration which includes an optional assignment (e....
virtual std::vector< SgNode * > get_traversalSuccessorContainer()
container of pointers to AST successor nodes used in the traversal overridden in every class by gener...
This class represents the concept of a C and C++ expression list.
bool ROSE_DLL_API isStatic(SgDeclarationStatement *stmt)
Check if a declaration has a "static' modifier.
std::string get_name(const SgNode *node)
Generate a useful name to describe the SgNode.
SgBasicBlock * ensureBasicBlockAsBodyOfDefaultOption(SgDefaultOptionStmt *cs)
Check if the body of a 'default option' statement is a SgBasicBlock, create one if not.
ROSE_DLL_API bool is_OpenMP_language()
This class represents the concept of a namespace name within the compiler.
This class represents a source file for a project (which may contian many source files and or directo...
ROSE_DLL_API SgInitializer * getInitializerOfExpression(SgExpression *n)
Get the initializer containing an expression if it is within an initializer.
Supporting class from copy mechanism within ROSE.
ROSE_DLL_API void fixTemplateDeclaration(SgTemplateDeclaration *stmt, SgScopeStatement *scope)
Fix the symbol table and set scope (only if scope in declaration is not already set).
ROSE_DLL_API void setLoopCondition(SgScopeStatement *loop, SgStatement *cond)
Set the condition statement of a loop, including While-loop, For-loop, and Do-While-loop.
std::string getMangledNameFromCache(SgNode *astNode)
Recursively print current and parent nodes. used within gdb to probe the context of a node.
SgDeclarationStatement * get_definingDeclaration() const
This is an access function for the SgDeclarationStatement::p_definingDeclaration data member (see tha...
ROSE_DLL_API std::set< SgNode * > getFrontendSpecificNodes()
Find a node by type using upward traversal.
ROSE_DLL_API bool isEquivalentFunctionType(const SgFunctionType *lhs, const SgFunctionType *rhs)
Test if two types are equivalent SgFunctionType nodes.
ROSE_DLL_API bool isUpcArrayWithThreads(SgArrayType *t)
Is a UPC array with dimension of X*THREADS.
ROSE_DLL_API SgBasicBlock * ensureBasicBlockAsTrueBodyOfIf(SgIfStmt *ifs)
Check if the true body of a 'if' statement is a SgBasicBlock, create one if not.
ROSE_DLL_API bool normalizeForLoopTest(SgForStatement *loop)
Normalize a for loop's test expression i<x is normalized to i<= (x-1) and i>x is normalized to i>= (x...
ROSE_DLL_API bool is_UPC_language()
std::vector< SgBreakStmt * > findBreakStmts(SgStatement *code, const std::string &fortranLabel="")
Find break statements inside a particular statement, stopping at nested loops or switches.
bool checkTypesAreEqual(SgType *typeA, SgType *typeB)
Collect all read and write references within stmt, which can be a function, a scope statement,...
SgTemplateFunctionDeclaration * get_templateDeclaration() const
Returns pointer to SgTemplateDeclaration from which instantiation is generated.
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,...
ROSE_DLL_API bool is_language_case_insensitive()
This class represents the base class for all types.
SgExpression * forallMaskExpression(SgForAllStatement *stmt)
Get the mask expression from the header of a SgForAllStatement.
bool isBodyStatement(SgStatement *s)
Check if a statement is a (true or false) body of a container-like parent, such as For,...
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,...
SgTemplateMemberFunctionDeclaration * get_templateDeclaration() const
Returns pointer to SgTemplateDeclaration from which instantiation is generated.
ROSE_DLL_API void replaceExpressionWithStatement(SgExpression *from, SageInterface::StatementGenerator *to)
Replace a given expression with a list of statements produced by a generator.
This class represents the concept of a C++ function call (which is an expression).
void changeAllBodiesToBlocks(SgNode *top, bool createEmptyBody=true)
Fix up ifs, loops, while, switch, Catch, UpirBodyStatement, etc. to have blocks as body components....
ROSE_DLL_API int instrumentEndOfFunction(SgFunctionDeclaration *func, SgStatement *s)
Instrument(Add a statement, often a function call) into a function right before the return points,...
This class represents the concept of a do-while statement.
This class represents the base class of a numbr of IR nodes that don't otherwise fit into the existin...
ROSE_DLL_API 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 bo...
ROSE_DLL_API bool isUseByAddressVariableRef(SgVarRefExp *ref)
Check if a variable reference is used by its address: including &a expression and foo(a) when type2 f...
This class represents the member function being called and must be assembled in the SgFunctionCall wi...
ROSE_DLL_API SgMemberFunctionDeclaration * getDefaultConstructor(SgClassDeclaration *classDeclaration)
Get the default constructor from the class declaration.
ROSE_DLL_API SgType * getFirstVarType(SgVariableDeclaration *decl)
Get the data type of the first initialized name of a declaration statement.
This class represents the concept of a switch.
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.
ROSE_DLL_API bool isMemberFunctionMemberReference(SgMemberFunctionRefExp *memberFunctionRefExp)
Find a node by type using upward traversal.
ROSE_DLL_API SgMemberFunctionDeclaration * getDefaultDestructor(SgClassDeclaration *classDeclaration)
Get the default destructor from the class declaration.
ROSE_DLL_API void replaceExpression(SgExpression *oldExp, SgExpression *newExp, bool keepOldExp=false)
Replace an expression with another, used for variable reference substitution and others....
virtual std::string class_name() const
returns a string representing the class name
void markNodeToBeUnparsed(SgNode *node, int physical_file_id)
Recursively print current and parent nodes. used within gdb to probe the context of a node.
ROSE_DLL_API int getDimensionCount(SgType *t)
Get the number of dimensions of an array type.
ROSE_DLL_API bool isUpcSharedArrayType(SgArrayType *array_type)
Check if an array type is a UPC shared type. ROSE AST represents a UPC shared array as regular array ...
SgDeclarationStatement * getNonInstantiatonDeclarationForClass(SgTemplateInstantiationMemberFunctionDecl *memberFunctionInstantiation)
Recursively print current and parent nodes. used within gdb to probe the context of a node.
void saveToPDF(SgNode *node, std::string filename)
Save AST into a pdf file. Start from a node to find its enclosing file node. The entire file's AST wi...
SgBasicBlock * makeSingleStatementBodyToBlock(SgStatement *singleStmt)
Make a single statement body to be a basic block. Its parent is if, while, catch, or upc_forall etc.
ROSE_DLL_API 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 ...
ROSE_DLL_API void moveStatementsBetweenBlocks(SgBasicBlock *sourceBlock, SgBasicBlock *targetBlock)
Move statements in first block to the second block (preserves order and rebuilds the symbol table).
ROSE_DLL_API bool isExtern(SgDeclarationStatement *stmt)
Check if a declaration has an "extern" modifier.
ROSE_DLL_API void appendExpressionList(SgExprListExp *, const std::vector< SgExpression * > &)
Append an expression list to a SgExprListExp, set the parent pointers also.
ROSE_DLL_API void moveUpPreprocessingInfo(SgStatement *stmt_dst, SgStatement *stmt_src, PreprocessingInfo::RelativePositionType src_position=PreprocessingInfo::undef, PreprocessingInfo::RelativePositionType dst_position=PreprocessingInfo::undef, bool usePrepend=false)
Identical to movePreprocessingInfo(), except for the stale name and confusing order of parameters....
ROSE_DLL_API SgInitializedName * convertRefToInitializedName(SgNode *current, bool coarseGrain=true)
Variable references can be introduced by SgVarRef, SgPntrArrRefExp, SgInitializedName,...
This class represents the concept of a block (not a basic block from control flow analysis).
ROSE_DLL_API int set_name(SgInitializedName *initializedNameNode, SgName new_name)
set_name of symbol in symbol table.
ROSE_DLL_API bool doLoopNormalization(SgFortranDo *loop)
Normalize a Fortran Do loop. Make the default increment expression (1) explicit.
void setSourcePositionAsTransformation(SgNode *node)
DQ (5/1/2012): New function with improved name.
ROSE_DLL_API bool is_UPC_dynamic_threads()
ROSE_DLL_API SgStatement * getLoopBody(SgScopeStatement *loop)
Routines to get and set the body of a loop.
void checkSymbolTables(SgNode *)
Recursively print current and parent nodes. used within gdb to probe the context of a node.
ROSE_DLL_API SgFunctionDeclaration * findMain(SgNode *currentNode)
top-down traversal from current node to find the main() function declaration
virtual SgName get_name() const =0
Access function for getting name from declarations or types internally.
ROSE_DLL_API bool isPointerType(SgType *t)
Is this type a pointer type? (Handles typedefs correctly)
ROSE_DLL_API SgStatement * getPreviousStatement(SgStatement *currentStmt, bool climbOutScope=true)
Get previous statement of the current statement. It may return a previous statement of a parent scope...
ROSE_DLL_API bool isPureVirtualClass(SgType *type, const ClassHierarchyWrapper &classHierarchy)
Check if a class type is a pure virtual class.
ROSE_DLL_API bool hasSameGlobalScope(SgStatement *statement_1, SgStatement *statement_2)
This is supporting the recognition of functions in header files from two different ASTs.
ROSE_DLL_API 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....
bool HasNoThrowAssign(const SgType *const inputType)
Collect all read and write references within stmt, which can be a function, a scope statement,...
const SgInitializedNamePtrList & get_args() const
Access function for p_args.
ROSE_DLL_API void changeBreakStatementsToGotos(SgStatement *loopOrSwitch)
If the given statement contains any break statements in its body, add a new label below the statement...
ROSE_DLL_API void reportModifiedStatements(const std::string &label, SgNode *node)
Connect variable reference to the right variable symbols when feasible, return the number of referenc...
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)
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,...
This class represents the concept of a member function declaration statement.
ROSE_DLL_API bool is_mixed_Fortran_and_Cxx_language()
Interface for creating a statement whose computation writes its answer into a given variable.
std::vector< SgVariableSymbol * > getSymbolsUsedInExpression(SgExpression *expr)
Find referenced symbols within an expression.
This class represents the concept of a function declaration statement.
ROSE_DLL_API SgSymbol * lookupSymbolInParentScopesIgnoringAliasSymbols(const SgName &name, SgScopeStatement *currentScope=NULL, SgTemplateParameterPtrList *templateParameterList=NULL, SgTemplateArgumentPtrList *templateArgumentList=NULL)
Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeSta...
ROSE_DLL_API int collectVariableReferencesInArrayTypes(SgLocatedNode *root, Rose_STL_Container< SgNode * > ¤tVarRefList)
Collect variable references in array types. The default NodeQuery::querySubTree() will miss variables...
SgCommaOpExp * insertBeforeUsingCommaOp(SgExpression *new_exp, SgExpression *anchor_exp)
Insert an expression (new_exp )before another expression (anchor_exp) has possible side effects,...
void markSubtreeToBeUnparsed(SgNode *root, int physical_file_id)
Recursively print current and parent nodes. used within gdb to probe the context of a node.
ROSE_DLL_API void setLoopBody(SgScopeStatement *loop, SgStatement *body)
Add a step statement to the end of a loop body Add a new label to the end of the loop,...
SgType * getBoolType(SgNode *n)
Get the right bool type according to C or C++ language input.
std::vector< SgDeclarationStatement * > getDependentDeclarations(SgStatement *stmt)
Get a statement's dependent declarations which declares the types used in the statement....
ROSE_DLL_API void convertFunctionDefinitionsToFunctionPrototypes(SgNode *node)
XXX This function operates on the new file used to support outlined function definitions....
ROSE_DLL_API void fixStructDeclaration(SgClassDeclaration *structDecl, SgScopeStatement *scope)
Fix symbols, parent and scope pointers. Used internally within appendStatment(), insertStatement() et...
ROSE_DLL_API std::set< SgStatement * > collectTransformedStatements(SgNode *node)
This collects the statements that are marked as transformed (useful in debugging).
ROSE_DLL_API SgSourceFile * getEnclosingSourceFile(SgNode *n, const bool includingSelf=false)
Find enclosing source file node.
ROSE_DLL_API void setExtern(SgDeclarationStatement *stmt)
Set a declaration as extern.
ROSE_DLL_API 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,...
ROSE_DLL_API SgClassDefinition * getEnclosingClassDefinition(SgNode *astnode, const bool includingSelf=false)
Get the closest class definition enclosing the specified AST node,.
ROSE_DLL_API PreprocessingInfo * findHeader(SgSourceFile *source_file, const std::string &header_file_name, bool isSystemHeader)
Find the preprocessingInfo node representing #include <header.h> or #include "header....
ROSE_DLL_API SgNonrealSymbol * lookupNonrealSymbolInParentScopes(const SgName &name, SgScopeStatement *currentScope=NULL, SgTemplateParameterPtrList *templateParameterList=NULL, SgTemplateArgumentPtrList *templateArgumentList=NULL)
Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeSta...
bool isStructurallyEquivalentAST(SgNode *tree1, SgNode *tree2)
Collect all read and write references within stmt, which can be a function, a scope statement,...
void outputGlobalFunctionTypeSymbolTable()
Output function type symbols in global function type symbol table.
ROSE_DLL_API bool insideSystemHeader(SgLocatedNode *node)
Set source position info(Sg_File_Info) as transformation generated for all SgNodes in memory pool.
ROSE_DLL_API bool isLastStatement(SgStatement *stmt)
Check if a statement is the last statement within its closed scope.
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.
ROSE_DLL_API bool mergeAssignmentWithDeclaration(SgExprStatement *assign_stmt, SgVariableDeclaration *decl, bool removeAssignStmt=true)
Merge an assignment into its upstream declaration statement. Callers should make sure the merge is se...
ROSE_DLL_API bool isMain(const SgNode *node)
Check if a SgNode is a main() function declaration.
ROSE_DLL_API SgBasicBlock * ensureBasicBlockAsBodyOfWhile(SgWhileStmt *ws)
Check if the body of a 'while' statement is a SgBasicBlock, create one if not.
std::vector< SgStatement * > getSwitchCases(SgSwitchStatement *sw)
Query a subtree to get all nodes of a given type, with an appropriate downcast.
ROSE_DLL_API bool unnormalizeForLoopInitDeclaration(SgForStatement *loop)
Undo the normalization of for loop's C99 init declaration. Previous record of normalization is used t...
ROSE_DLL_API void moveCommentsToNewStatement(SgStatement *sourceStatement, const std::vector< int > &indexList, SgStatement *targetStatement, bool surroundingStatementPreceedsTargetStatement)
Relocate comments and CPP directives from one statement to another.
ROSE_DLL_API SgClassSymbol * lookupClassSymbolInParentScopes(const SgName &name, SgScopeStatement *currentScope=NULL, SgTemplateArgumentPtrList *templateArgumentList=NULL)
Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeSta...
ROSE_DLL_API 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 cutPrepro...
bool IsPod(const SgType *const inputType)
Collect all read and write references within stmt, which can be a function, a scope statement,...
void clearUnusedVariableSymbols(SgNode *root=NULL)
Clear those variable symbols with unknown type (together with initialized names) which are also not r...
ROSE_DLL_API void setStatic(SgDeclarationStatement *stmt)
Set a declaration as static.
ROSE_DLL_API SgStatement * getLastStatement(SgScopeStatement *scope)
get the last statement within a scope, return NULL if it does not exit
ROSE_DLL_API SgStatement * lastFrontEndSpecificStatement(SgGlobal *globalScope)
Function to delete AST subtree's nodes only, users must take care of any dangling pointers,...
ROSE_DLL_API SgNode * getSgNodeFromAbstractHandleString(const std::string &input_string)
Obtain a matching SgNode from an abstract handle string.
ROSE_DLL_API SgGlobal * getGlobalScope(const SgNode *astNode)
Traverse back through a node's parents to find the enclosing global scope.
std::vector< SgExpression * > get_C_array_dimensions(const SgArrayType &arrtype)
returns the array dimensions in an array as defined for arrtype
std::set< unsigned int > collectSourceSequenceNumbers(SgNode *astNode)
Collect all read and write references within stmt, which can be a function, a scope statement,...
ROSE_DLL_API PreprocessingInfo * attachArbitraryText(SgLocatedNode *target, const std::string &text, PreprocessingInfo::RelativePositionType position=PreprocessingInfo::before)
Attach an arbitrary string to a located node. A workaround to insert irregular statements or vendor-s...
ROSE_DLL_API void resetInternalMapsForTargetStatement(SgStatement *sourceStatement)
Function to delete AST subtree's nodes only, users must take care of any dangling pointers,...
ROSE_DLL_API void setSourcePosition(SgNode *node)
Set the source code positon for the current (input) node.
ROSE_DLL_API SgInitializedName * getLoopIndexVariable(SgNode *loop)
Return the loop index variable for a for loop.
void resetScopeNumbers(SgFunctionDefinition *functionDeclaration)
Assigns unique numbers to each SgScopeStatement of a function.
std::vector< SgFile * > generateFileList()
Returns STL vector of SgFile IR node pointers.
ROSE_DLL_API SgTemplateInstantiationMemberFunctionDecl * buildForwardFunctionDeclaration(SgTemplateInstantiationMemberFunctionDecl *memberFunctionInstantiation)
Generate a non-defining (forward) declaration from a defining function declaration.
bool isIndexOperator(SgExpression *exp)
Is an overloaded operator an index operator (also referred to as call or subscript operators)....
This class represents the notion of an expression. Expressions are derived from SgLocatedNodes,...
ROSE_DLL_API bool isNonconstReference(SgType *t)
Is this type a non-constant reference type? (Handles typedefs correctly)
void clearMangledNameCache(SgGlobal *globalScope)
Support for faster mangled name generation (caching avoids recomputation).
ROSE_DLL_API SgAssignInitializer * splitExpression(SgExpression *from, std::string newName="")
Replace an expression with a temporary variable and an assignment statement.
void whereAmI(SgNode *node)
Diagnostic function for tracing back through the parent list to understand at runtime where in the AS...
void annotateExpressionsWithUniqueNames(SgProject *project)
Generate unique names for expressions and attach the names as persistent attributes ("UniqueNameAttri...
ROSE_DLL_API void prependStatementList(const std::vector< SgStatement * > &stmt, SgScopeStatement *scope=NULL)
prepend a list of statements to the beginning of the current scope, handling side effects as appropri...
ROSE_DLL_API std::list< SgClassType * > getClassTypeChainForMemberReference(SgExpression *refExp)
Find a node by type using upward traversal.
void detectCycleInType(SgType *type, const std::string &from)
Collect all read and write references within stmt, which can be a function, a scope statement,...
RelativePositionType
MK: Enum type to store if the directive goes before or after the corresponding line of source code.
void checkAccessPermissions(SgNode *)
Recursively print current and parent nodes. used within gdb to probe the context of a node.
std::map< std::string, SgNode * > local_name_to_node_map
Global map of name collisions to support generateUniqueNameForUseAsIdentifier() function.
ROSE_DLL_API void convertAllForsToWhiles(SgNode *top)
Add a step statement to the end of a loop body Add a new label to the end of the loop,...
bool isPrefixOperatorName(const SgName &functionName)
Check for proper names of possible prefix operators (used in isPrefixOperator()).
void visit(SgNode *node)
this method is called at every traversed node.
std::vector< SgContinueStmt * > findContinueStmts(SgStatement *code, const std::string &fortranLabel="")
Find all continue statements inside a particular statement, stopping at nested loops.
ROSE_DLL_API void moveVariableDeclaration(SgVariableDeclaration *decl, SgScopeStatement *target_scope)
Move a variable declaration to a new scope, handle symbol, special scopes like For loop,...
std::vector< SgGotoStatement * > findGotoStmts(SgStatement *scope, SgLabelStatement *l)
Query a subtree to get all nodes of a given type, with an appropriate downcast.
to specify a construct using a specifier Can be used alone or with parent handles when relative speci...
ROSE_DLL_API SgNamespaceSymbol * lookupNamespaceSymbolInParentScopes(const SgName &name, SgScopeStatement *currentScope=NULL)
Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeSta...
ROSE_DLL_API bool isSameFunction(SgFunctionDeclaration *func1, SgFunctionDeclaration *func2)
Check if two function declarations refer to the same one. Two function declarations are the same when...
ROSE_DLL_API bool isUpcSharedType(SgType *t, SgModifierType **mod_type_out=NULL)
Check if a type is a UPC shared type, including shared array, shared pointers etc....
This class represents the concept of an instantiation of member function template or a member functio...
ROSE_DLL_API void outputFileIds(SgNode *node)
Connect variable reference to the right variable symbols when feasible, return the number of referenc...
ROSE_DLL_API bool isStrictIntegerType(SgType *t)
Check if a type is an integral type, only allowing signed/unsigned short, int, long,...
ROSE_DLL_API bool isLambdaCapturedVariable(SgVarRefExp *varRef)
check if a variable reference is this->a[i] inside of a lambda function
ROSE_DLL_API bool isReferenceType(SgType *t)
Is this type a const or non-const reference type? (Handles typedefs correctly)
Functions that are useful when operating on the AST.
ROSE_DLL_API SgExprListExp * getEnclosingExprListExp(SgNode *astNode, const bool includingSelf=false)
Get the enclosing SgExprListExp (used as part of function argument index evaluation in subexpressions...
ROSE_DLL_API SgScopeStatement * findEnclosingLoop(SgStatement *s, const std::string &fortranLabel="", bool stopOnSwitches=false)
Find the closest loop outside the given statement; if fortranLabel is not empty, the Fortran label of...
ROSE_DLL_API bool is_OpenCL_language()
void checkForInitializers(SgNode *node)
Collect all read and write references within stmt, which can be a function, a scope statement,...
This class represents the concept of a declaration list.
ROSE_DLL_API 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.
ROSE_DLL_API SgBasicBlock * ensureBasicBlockAsBodyOfUpcForAll(SgUpcForAllStatement *fs)
Check if the body of a 'upc_forall' statement is a SgBasicBlock, create one if not.
This class represents template argument within the use of a template to build an instantiation.
ROSE_DLL_API SgType * getAssociatedTypeFromFunctionTypeList(SgExpression *actual_argument_expression)
Get the type of the associated argument expression from the function type.
bool isPrototypeInScope(SgScopeStatement *scope, SgFunctionDeclaration *functionDeclaration, SgDeclarationStatement *startingAtDeclaration)
Assigns unique numbers to each SgScopeStatement of a function.
ROSE_DLL_API bool templateArgumentListEquivalence(const SgTemplateArgumentPtrList &list1, const SgTemplateArgumentPtrList &list2)
Verify that 2 SgTemplateArgumentPtrList are equivalent.
ROSE_DLL_API bool isStructDeclaration(SgNode *node)
Check if a SgNode is a declaration for a structure.
void setBaseTypeDefiningDeclaration(SgVariableDeclaration *var_decl, SgDeclarationStatement *base_decl)
a better version for SgVariableDeclaration::set_baseTypeDefininingDeclaration(), handling all side ef...
AncestorNode * ancestor(SgNode *n)
finds an ancestor node with a given type
SgDeclarationStatement * get_firstNondefiningDeclaration() const
This is an access function for the SgDeclarationStatement::p_firstNondefiningDeclaration data member ...
ROSE_DLL_API SgUpirFieldBodyStatement * findEnclosingUpirFieldBodyStatement(SgStatement *s)
Find enclosing OpenMP clause body statement from s. If s is already one, return it directly.
ROSE_DLL_API SgBasicBlock * ensureBasicBlockAsBodyOfFor(SgForStatement *fs)
Check if the body of a 'for' statement is a SgBasicBlock, create one if not.
ROSE_DLL_API SgFunctionDefinition * getEnclosingProcedure(SgNode *n, const bool includingSelf=false)
Find the function definition.
ROSE_DLL_API void cleanupNontransformedBasicBlockNode()
Remove unused basic block IR nodes added as part of normalization.
std::pair< SgVariableDeclaration *, SgExpression * > createTempVariableForExpression(SgExpression *expression, SgScopeStatement *scope, bool initializeInDeclaration, SgAssignOp **reEvaluate=NULL)
Given an expression, generates a temporary variable whose initializer optionally evaluates that expre...
ROSE_DLL_API void appendStatement(SgStatement *stmt, SgScopeStatement *scope=NULL)
Append a statement to the end of the current scope, handle side effect of appending statements,...
void dumpPreprocInfo(SgLocatedNode *locatedNode)
Dumps a located node's preprocessing information.
Class for traversing the AST.
ROSE_DLL_API std::vector< SgFunctionDeclaration * > generateFunctionDefinitionsList(SgNode *node)
Function to delete AST subtree's nodes only, users must take care of any dangling pointers,...
ROSE_DLL_API bool isVolatileType(SgType *t)
Is this a volatile type?
void clearSharedGlobalScopes(SgProject *project)
Collect all read and write references within stmt, which can be a function, a scope statement,...
This class represents strings within the IR nodes.
SgBasicBlock * ensureBasicBlockAsBodyOfCaseOption(SgCaseOptionStmt *cs)
Check if the body of a 'case option' statement is a SgBasicBlock, create one if not.
ROSE_DLL_API void recordNormalizations(SgStatement *s)
Record where normalization have been done so that we can preform denormalizations as required for the...
ROSE_DLL_API void replaceSubexpressionWithStatement(SgExpression *from, SageInterface::StatementGenerator *to)
Similar to replaceExpressionWithStatement, but with more restrictions.
void initializeSwitchStatement(SgSwitchStatement *switchStatement, SgStatement *item_selector, SgStatement *body)
Support function used for variable declarations in conditionals.
ROSE_DLL_API void appendExpression(SgExprListExp *, SgExpression *)
Append an expression to a SgExprListExp, set the parent pointer also.
ROSE_DLL_API bool skipTranslateToUseCppDeclaration(PreprocessingInfo *currentPreprocessingInfo)
Connect variable reference to the right variable symbols when feasible, return the number of referenc...
ROSE_DLL_API void translateScopeToUseCppDeclarations(SgScopeStatement *scope)
Connect variable reference to the right variable symbols when feasible, return the number of referenc...
ROSE_DLL_API bool statementCanBeTransformed(SgStatement *stmt)
If header file unparsing and token-based unparsing are used, then some statements in header files use...
bool IsBaseOf(const SgType *const inputBaseType, const SgType *const inputDerivedType)
Collect all read and write references within stmt, which can be a function, a scope statement,...
ROSE_DLL_API SgGlobal * getFirstGlobalScope(SgProject *project)
return the first global scope under current project
ROSE_DLL_API bool isDefaultConstructible(SgType *type)
Is a type default constructible? This may not quite work properly.
ROSE_DLL_API SgVariableSymbol * lookupVariableSymbolInParentScopes(const SgName &name, SgScopeStatement *currentScope=NULL)
Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeSta...
ROSE_DLL_API void removeStatement(SgStatement *stmt, bool autoRelocatePreprocessingInfo=true)
Remove a statement from its attach point of the AST. Automatically keep its associated preprocessing ...
std::vector< SgInitializedName * > getInParameters(const SgInitializedNamePtrList ¶ms)
Get a vector of Jovial input parameters from the function parameter list (may work for Fortran in the...
ROSE_DLL_API void setOperand(SgExpression *target, SgExpression *operand)
Set operands for expressions with single operand, such as unary expressions. handle file info,...
This class represents the concept of a declaration statement.
label_type_enum
Type of label used (fortran only)
bool IsAbstract(const SgType *const inputType)
Collect all read and write references within stmt, which can be a function, a scope statement,...
ROSE_DLL_API void moveForStatementIncrementIntoBody(SgForStatement *f)
Add a step statement to the end of a loop body Add a new label to the end of the loop,...
SgStatement * lastStatementOfScopeWithTokenInfo(SgScopeStatement *scope, std::map< SgNode *, TokenStreamSequenceToNodeMapping * > &tokenStreamSequenceMap)
Used to support token unparsing (when the output the trailing token sequence).
ROSE_DLL_API 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 bo...
void addVarRefExpFromArrayDimInfo(SgNode *astNode, Rose_STL_Container< SgNode * > &NodeList_t)
Find all SgPntrArrRefExp under astNode, then add SgVarRefExp (if any) of SgPntrArrRefExp's dim_info i...
NodeType * getEnclosingNode(const SgNode *astNode, const bool includingSelf=false)
Find a node by type using upward traversal.
ROSE_DLL_API void fixClassDeclaration(SgClassDeclaration *classDecl, SgScopeStatement *scope)
Fix symbols, parent and scope pointers. Used internally within appendStatment(), insertStatement() et...
ROSE_DLL_API SgSymbol * lookupSymbolInParentScopes(const SgName &name, SgScopeStatement *currentScope=NULL, SgTemplateParameterPtrList *templateParameterList=NULL, SgTemplateArgumentPtrList *templateArgumentList=NULL)
Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeSta...
bool IsTrivial(const SgType *const inputType)
Collect all read and write references within stmt, which can be a function, a scope statement,...
bool IsClass(const SgType *const inputType)
strip off typedef and modifer types, then check if a type is a class type, excluding union type.
ROSE_DLL_API bool hasSimpleChildrenList(SgScopeStatement *scope)
Check if a scope statement has a simple children statement list so insert additional statements under...
ROSE_DLL_API size_t getArrayElementCount(SgArrayType *t)
Calculate the number of elements of an array type: dim1* dim2*... , assume element count is 1 for int...
ROSE_DLL_API void replaceStatement(SgStatement *oldStmt, SgStatement *newStmt, bool movePreprocessinInfo=false)
Replace a statement with another. Move preprocessing information from oldStmt to newStmt if requested...
This class represents the concept of a namespace definition.
ROSE_DLL_API SgFunctionType * findFunctionType(SgType *return_type, SgFunctionParameterTypeList *typeList)
Find the function type matching a function signature plus a given return type.
ROSE_DLL_API void displayScope(SgScopeStatement *scope)
Find a node by type using upward traversal.
void resetMangledNameCache(SgGlobal *globalScope)
Recursively print current and parent nodes. used within gdb to probe the context of a node.
ROSE_DLL_API int gensym_counter
An internal counter for generating unique SgName.
This class represents the concept of a template declaration.
ROSE_DLL_API void setLoopStride(SgNode *loop, SgExpression *stride)
Set the stride(step) of a loop 's incremental expression, regardless the expression types (i+=s; i= i...
ROSE_DLL_API bool isConstantFalse(SgExpression *e)
Check if a bool or int constant expression evaluates to be a false value.
bool IsEnum(const SgType *const inputType)
Collect all read and write references within stmt, which can be a function, a scope statement,...
ROSE_DLL_API int suggestNextNumericLabel(SgFunctionDefinition *func_def)
Suggest next usable (non-conflicting) numeric label value for a Fortran function definition scope.
bool IsStandardLayout(const SgType *const inputType)
Collect all read and write references within stmt, which can be a function, a scope statement,...
ROSE_DLL_API SgFunctionDeclaration * getEnclosingFunctionDeclaration(SgNode *astNode, const bool includingSelf=false)
Find the enclosing function declaration, including its derived instances like isSgProcedureHeaderStat...
This class represents the base class for all IR nodes within Sage III.
ROSE_DLL_API std::set< SgLabelStatement * > findUnusedLabels(SgNode *top)
Find unused labels which are not targets of any goto statements.
ROSE_DLL_API SgInitializedName * getFirstInitializedName(SgVariableDeclaration *decl)
Get the first initialized name of a declaration statement.
ROSE_DLL_API bool isEqualToIntConst(SgExpression *e, int value)
Check if a SgIntVal node has a given value.
std::vector< SgInitializedName * > getOutParameters(const SgInitializedNamePtrList ¶ms)
Get a vector of Jovial output parameters from the function parameter list (may work for Fortran in th...
std::map< std::string, int > local_name_collision_map
Global map of name collisions to support generateUniqueNameForUseAsIdentifier() function.
This class represents the concept of a class name within the compiler.
ROSE_DLL_API SgStatement * getLoopCondition(SgScopeStatement *loop)
Routines to get the condition of a loop. It recognize While-loop, For-loop, and Do-While-loop.
ROSE_DLL_API SgType * lookupNamedTypeInParentScopes(const std::string &type_name, SgScopeStatement *scope=NULL)
Lookup a named type based on its name, bottomup searching from a specified scope. Note name collison ...
SgInitializedName & getFirstVariable(SgVariableDeclaration &vardecl)
convenience function that returns the first initialized name in a list of variable declarations.
ROSE_DLL_API void fixFunctionDeclaration(SgFunctionDeclaration *stmt, SgScopeStatement *scope)
Fix the symbol table and set scope (only if scope in declaration is not already set).
This class represents the concept of an instantiation of function template.
ROSE_DLL_API std::vector< SgNode * > astIntersection(SgNode *original, SgNode *copy, SgCopyHelp *help=NULL)
Compute the intersection set for two ASTs.
ROSE_DLL_API int fixVariableReferences(SgNode *root, bool cleanUnusedSymbol=true)
Connect variable reference to the right variable symbols when feasible, return the number of referenc...
ROSE_DLL_API bool isDataMemberReference(SgVarRefExp *varRefExp)
Find a node by type using upward traversal.
ROSE_DLL_API PreprocessingInfo * insertHeader(SgSourceFile *source_file, const std::string &header_file_name, bool isSystemHeader, bool asLastHeader)
Insert #include "filename" or #include <filename> (system header) onto the global scope of a source f...
ROSE_DLL_API std::set< SgStatement * > collectModifiedStatements(SgNode *node)
This collects the statements that are marked as modified (a flag automatically set by all set_* gener...
ROSE_DLL_API SgStatement * copyStatement(SgStatement *s)
Deep copy a statement.
ROSE_DLL_API void setFortranNumericLabel(SgStatement *stmt, int label_value, SgLabelSymbol::label_type_enum label_type=SgLabelSymbol::e_start_label_type, SgScopeStatement *label_scope=NULL)
Set a numerical label for a Fortran statement. The statement should have a enclosing function definit...
ROSE_DLL_API SgVariableSymbol * appendArg(SgFunctionParameterList *, SgInitializedName *)
Append an argument to SgFunctionParameterList, transparently set parent,scope, and symbols for argume...
ROSE_DLL_API void splitExpressionIntoBasicBlock(SgExpression *expr)
Split long expressions into blocks of statements.
This class represents the concept of a catch within a try-catch construct used in C++ exception handl...
ROSE_DLL_API bool mergeDeclarationWithAssignment(SgVariableDeclaration *decl, SgExprStatement *assign_stmt)
Merge a declaration statement into a matching followed variable assignment. Callers should make sure ...
This class represents the notion of a declared variable.
ROSE_DLL_API bool hasUpcSharedType(SgType *t, SgModifierType **mod_type_out=NULL)
Has a UPC shared type of any kinds (shared-to-shared, private-to-shared, shared-to-private,...
ROSE_DLL_API void setRhsOperand(SgExpression *target, SgExpression *rhs)
set left hand operand for binary expression
ROSE_DLL_API void moveDeclarationToAssociatedNamespace(SgDeclarationStatement *declarationStatement)
Relocate the declaration to be explicitly represented in its associated namespace (required for some ...
ROSE_DLL_API void setOneSourcePositionForTransformation(SgNode *root)
Set current node's source position as transformation generated.
void recursivePrintCurrentAndParent(SgNode *n)
Recursively print current and parent nodes. used within gdb to probe the context of a node.
This class represents the concept of a C or C++ label statement.
ROSE_DLL_API void fixLabelStatement(SgLabelStatement *label_stmt, SgScopeStatement *scope)
Fix symbol table for SgLabelStatement. Used Internally when the label is built without knowing its ta...
ROSE_DLL_API SgFunctionDeclaration * buildFunctionPrototype(SgFunctionDeclaration *functionDeclaration)
Function to delete AST subtree's nodes only, users must take care of any dangling pointers,...
ROSE_DLL_API bool isAssignable(SgType *type)
Is a type assignable? This may not quite work properly.
void collectVarRefs(SgLocatedNode *root, std::vector< SgVarRefExp * > &result)
Collect all variable references in a subtree.
ROSE_DLL_API std::vector< SgC_PreprocessorDirectiveStatement * > translateStatementToUseCppDeclarations(SgStatement *statement, SgScopeStatement *scope)
Connect variable reference to the right variable symbols when feasible, return the number of referenc...
ROSE_DLL_API bool templateArgumentEquivalence(SgTemplateArgument *arg1, SgTemplateArgument *arg2)
Verify that 2 SgTemplateArgument are equivalent (same type, same expression, or same template declara...
ROSE_DLL_API SgScopeStatement * getScope(const SgNode *astNode)
Get the closest scope from astNode. Return astNode if it is already a scope.
SgNamespaceDefinitionStatement * enclosingNamespaceScope(SgDeclarationStatement *declaration)
Find the enclosing namespace of a declaration.
bool functionCallExpressionPreceedsDeclarationWhichAssociatesScope(SgFunctionCallExp *functionCall)
Recursively print current and parent nodes. used within gdb to probe the context of a node.
ROSE_DLL_API SgFunctionSymbol * lookupTemplateMemberFunctionSymbolInParentScopes(const SgName &functionName, SgFunctionType *ftype, SgTemplateParameterPtrList *tplparams, SgScopeStatement *currentScope=NULL)
Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeSta...
ROSE_DLL_API bool insideHeader(SgLocatedNode *node)
Check if a node is from a header file.
ROSE_DLL_API void fixVariableDeclaration(SgVariableDeclaration *varDecl, SgScopeStatement *scope)
Patch up symbol, scope, and parent information when a SgVariableDeclaration's scope is known.
ROSE_DLL_API void outputSharedNodes(SgNode *node)
Find a node by type using upward traversal.
ROSE_DLL_API SgBasicBlock * ensureBasicBlockAsBodyOfDoWhile(SgDoWhileStmt *ws)
Check if the body of a 'do .. while' statement is a SgBasicBlock, create one if not.
ROSE_DLL_API bool isUpcPrivateToSharedType(SgType *t)
Is a UPC private-to-shared pointer? SgPointerType comes first compared to SgModifierType with UPC inf...
SgType * UnderlyingType(SgType *type)
Collect all read and write references within stmt, which can be a function, a scope statement,...
ROSE_DLL_API bool isRestrictType(SgType *t)
Is this a restrict type?
This class represents the notion of an value (expression value).
ROSE_DLL_API bool isPointerToNonConstType(SgType *type)
Is this a pointer to a non-const type? Note that this function will return true for const pointers po...
ROSE_DLL_API bool is_Cxx_language()
std::map< SgNode *, std::string > local_node_to_name_map
Global map of name collisions to support generateUniqueNameForUseAsIdentifier() function.
ROSE_DLL_API bool normalizeForLoopInitDeclaration(SgForStatement *loop)
Normalize loop init stmt by promoting the single variable declaration statement outside of the for lo...
ROSE_DLL_API bool isUnionDeclaration(SgNode *node)
Check if a SgNode is a declaration for a union.
ROSE_DLL_API void appendStatementList(const std::vector< SgStatement * > &stmt, SgScopeStatement *scope=NULL)
Append a list of statements to the end of the current scope, handle side effect of appending statemen...
void rebuildSymbolTable(SgScopeStatement *scope)
Regenerate the symbol table.
SgNode * get_parent() const
Access function for parent node.
ROSE_DLL_API SgEnumSymbol * lookupEnumSymbolInParentScopes(const SgName &name, SgScopeStatement *currentScope=NULL)
Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeSta...
bool HasNoThrowCopy(const SgType *const inputType)
Collect all read and write references within stmt, which can be a function, a scope statement,...
ROSE_DLL_API bool is_C_language()
void addMessageStatement(SgStatement *stmt, std::string message)
Function to add "C" style comment to statement.
void set_parent(SgNode *parent)
All nodes in the AST contain a reference to a parent node.
bool IsPolymorphic(const SgType *const inputType)
Collect all read and write references within stmt, which can be a function, a scope statement,...
ROSE_DLL_API std::set< SgLocatedNode * > collectModifiedLocatedNodes(SgNode *node)
This collects the SgLocatedNodes that are marked as modified (a flag automatically set by all set_* g...
ROSE_DLL_API bool isCallToParticularFunction(SgFunctionDeclaration *decl, SgExpression *e)
Recursively print current and parent nodes. used within gdb to probe the context of a node.
ROSE_DLL_API SgBasicBlock * ensureBasicBlockAsBodyOfCatch(SgCatchOptionStmt *cos)
Check if the body of a 'catch' statement is a SgBasicBlock, create one if not.
bool HasTrivialConstructor(const SgType *const inputType)
Collect all read and write references within stmt, which can be a function, a scope statement,...
ROSE_DLL_API void convertForToWhile(SgForStatement *f)
Add a step statement to the end of a loop body Add a new label to the end of the loop,...
ROSE_DLL_API bool language_may_contain_nondeclarations_in_scope()
ROSE_DLL_API bool loopUnrolling(SgForStatement *loop, size_t unrolling_factor)
Unroll a target loop with a specified unrolling factor. It handles steps larger than 1 and adds a fri...
ROSE_DLL_API 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 ...
bool IsEmpty(const SgType *const inputType)
Collect all read and write references within stmt, which can be a function, a scope statement,...
A persistent attribute to represent a unique name for an expression.
This class represents the concept of a scope in C++ (e.g. global scope, fuction scope,...
bool IsLiteralType(const SgType *const inputType)
Collect all read and write references within stmt, which can be a function, a scope statement,...
void computeUniqueNameForUseAsIdentifier(SgNode *astNode)
Traversal to set the global map of names to node and node to names.collisions to support generateUniq...
ROSE_DLL_API 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.
ROSE_DLL_API bool isScalarType(SgType *t)
Is this a scalar type?
ROSE_DLL_API void replaceMacroCallsWithExpandedStrings(SgPragmaDeclaration *target)
Check if a pragma declaration node has macro calls attached, if yes, replace macro calls within the p...
ROSE_DLL_API bool isTemplateInstantiationNode(SgNode *node)
Function to delete AST subtree's nodes only, users must take care of any dangling pointers,...
void initializeWhileStatement(SgWhileStmt *whileStatement, SgStatement *condition, SgStatement *body, SgStatement *else_body)
Support function used for variable declarations in conditionals.
ROSE_DLL_API void updateDefiningNondefiningLinks(SgFunctionDeclaration *func, SgScopeStatement *scope)
Update defining and nondefining links due to a newly introduced function declaration....
ROSE_DLL_API void deepDelete(SgNode *root)
Deep delete a sub AST tree. It uses postorder traversal to delete each child node....
ROSE_DLL_API SgFunctionDeclaration * replaceDefiningFunctionDeclarationWithFunctionPrototype(SgFunctionDeclaration *functionDeclaration)
Function to delete AST subtree's nodes only, users must take care of any dangling pointers,...
ROSE_DLL_API void removeConsecutiveLabels(SgNode *top)
Remove consecutive labels.
bool hasTemplateSyntax(const SgName &name)
Collect all read and write references within stmt, which can be a function, a scope statement,...
ROSE_DLL_API bool forLoopNormalization(SgForStatement *loop, bool foldConstant=true)
Normalize a for loop, return true if successful.
ROSE_DLL_API bool is_mixed_C_and_Cxx_language()
This class represents the concept of a C or C++ variable declaration.
ROSE_DLL_API bool normalizeForLoopIncrement(SgForStatement *loop)
Add a step statement to the end of a loop body Add a new label to the end of the loop,...
ROSE_DLL_API bool is_mixed_Fortran_and_C_language()
ROSE_DLL_API size_t getUpcSharedBlockSize(SgModifierType *mod_type)
Get the block size of a UPC shared modifier type.
void setParameterList(actualFunction *func, SgFunctionParameterList *paralist)
Set parameter list for a function declaration, considering existing parameter list etc.
ROSE_DLL_API void prependStatement(SgStatement *stmt, SgScopeStatement *scope=NULL)
Prepend a statement to the beginning of the current scope, handling side effects as appropriate.
ROSE_DLL_API void deleteAST(SgNode *node)
Function to delete AST subtree's nodes only, users must take care of any dangling pointers,...
ROSE_DLL_API bool is_CAF_language()
This class represents the concept of a scope in C++ (e.g. global scope, fuction scope,...
std::pair< SgStatement *, SgInitializedName * > wrapFunction(SgFunctionDeclaration &definingDeclaration, SgName newName)
moves the body of a function f to a new function f; f's body is replaced with code that forwards the ...
bool getForLoopInformations(SgForStatement *for_loop, SgVariableSymbol *&iterator, SgExpression *&lower_bound, SgExpression *&upper_bound, SgExpression *&stride)
Add a step statement to the end of a loop body Add a new label to the end of the loop,...
ROSE_DLL_API SgFunctionSymbol * lookupFunctionSymbolInParentScopes(const SgName &functionName, SgScopeStatement *currentScope=NULL)
look up the first matched function symbol in parent scopes given only a function name,...
ROSE_DLL_API SgStatement * findSurroundingStatementFromSameFile(SgStatement *targetStmt, bool &surroundingStatementPreceedsTargetStatement)
Supporting function to comment relocation in insertStatement() and removeStatement().
ROSE_DLL_API bool isCanonicalDoLoop(SgFortranDo *loop, SgInitializedName **ivar, SgExpression **lb, SgExpression **ub, SgExpression **step, SgStatement **body, bool *hasIncrementalIterationSpace, bool *isInclusiveUpperBound)
Check if a Fortran Do loop has a complete canonical form: Do I=1, 10, 1.
bool IsUnion(const SgType *const inputType)
Collect all read and write references within stmt, which can be a function, a scope statement,...
ROSE_DLL_API void collectUseByAddressVariableRefs(const SgStatement *s, std::set< SgVarRefExp * > &varSetB)
Collect variable references involving use by address: including &a expression and foo(a) when type2 f...
ROSE_DLL_API void myRemoveStatement(SgStatement *stmt)
A special purpose statement removal function, originally from inlinerSupport.h, Need Jeremiah's atten...
ROSE_DLL_API void insertStatementAfterLastDeclaration(SgStatement *stmt, SgScopeStatement *scope)
Insert a statement after the last declaration within a scope. The statement will be prepended to the ...
ROSE_DLL_API void changeContinuesToGotos(SgStatement *stmt, SgLabelStatement *label)
Change continue statements in a given block of code to gotos to a label.
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 ...
ROSE_DLL_API 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....
bool declarationPreceedsDefinition(SgDeclarationStatement *nonDefiningDeclaration, SgDeclarationStatement *definingDeclaration)
Check if a defining declaration comes before of after the non-defining declaration.
ROSE_DLL_API SgFile * getEnclosingFileNode(SgNode *astNode)
get the SgFile node from current node
ROSE_DLL_API void wrapAllTemplateInstantiationsInAssociatedNamespaces(SgProject *root)
Function to delete AST subtree's nodes only, users must take care of any dangling pointers,...
std::string generateUniqueNameForUseAsIdentifier(SgDeclarationStatement *declaration)
Generate a useful name to support construction of identifiers from declarations.
ROSE_DLL_API 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,...
This class represents a source project, with a list of SgFile objects and global information about th...
ROSE_DLL_API SgStatement * getNextStatement(SgStatement *currentStmt)
Get next statement within the same scope of current statement.
bool isPostfixOperator(SgExpression *exp)
Is an overloaded operator a postfix operator. (e.g. ).
This class represents the notion of a statement.
ROSE_DLL_API bool is_Fortran_language()
ROSE_DLL_API SgNode * replaceWithPattern(SgNode *anchor, SgNode *new_pattern)
Replace an anchor node with a specified pattern subtree with optional SgVariantExpression....
ROSE_DLL_API void setOneSourcePositionNull(SgNode *node)
Set current node's source position as NULL.
ROSE_DLL_API void removeAllOriginalExpressionTrees(SgNode *top)
Set original expression trees to NULL for SgValueExp or SgCastExp expressions, so you can change the ...
ROSE_DLL_API SgTypedefSymbol * lookupTypedefSymbolInParentScopes(const SgName &name, SgScopeStatement *currentScope=NULL)
Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeSta...
ROSE_DLL_API void setLoopLowerBound(SgNode *loop, SgExpression *lb)
Set the lower bound of a loop header for (i=lb; ...)
ROSE_DLL_API SgExprStatement * splitVariableDeclaration(SgVariableDeclaration *decl)
Split a variable declaration with an rhs assignment into two statements: a declaration and an assignm...
ROSE_DLL_API AbstractHandle::abstract_handle * buildAbstractHandle(SgNode *)
Build an abstract handle from an AST node, reuse previously built handle when possible.
For preprocessing information including source comments, #include , #if, #define, etc.
bool ROSE_DLL_API isAncestor(SgNode *node1, SgNode *node2)
check if node1 is a strict ancestor of node 2. (a node is not considered its own ancestor)
ROSE_DLL_API bool loopTiling(SgForStatement *loopNest, size_t targetLevel, size_t tileSize)
Tile the n-level (starting from 1) loop of a perfectly nested loop nest using tiling size s.
This class represents the notion of an initializer for a variable declaration or expression in a func...
ROSE_DLL_API bool isLambdaFunction(SgFunctionDeclaration *func)
Check if a function declaration is a C++11 lambda function.
ROSE_DLL_API SgTemplateVariableSymbol * lookupTemplateVariableSymbolInParentScopes(const SgName &name, SgTemplateParameterPtrList *tplparams, SgTemplateArgumentPtrList *tplargs, SgScopeStatement *currentScope=NULL)
Find a symbol in current and ancestor scopes for a given variable name, starting from top of ScopeSta...
This class represents the concept of a C or C++ statement which contains a expression.
ROSE_DLL_API SgStatement * getFirstStatement(SgScopeStatement *scope, bool includingCompilerGenerated=false)
Get the first statement within a scope, return NULL if it does not exist. Skip compiler-generated sta...
ROSE_DLL_API SgProject * getProject()
Get the current SgProject IR Node.
std::string declarationPositionString(const SgDeclarationStatement *declaration)
Generate a unique string from the source file position information.
This class represents the variable declaration or variable initialization withn a for loop.
bool ROSE_DLL_API isMutable(SgInitializedName *name)
True if an SgInitializedName is "mutable' (has storage modifier set)
ROSE_DLL_API void removeJumpsToNextStatement(SgNode *)
Remove jumps whose label is immediately after the jump. Used to clean up inlined code fragments.
This class represents the concept of a name within the compiler.
This class represents the concept of a C Assembler statement (untested).
ROSE_DLL_API 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,...
ROSE_DLL_API std::vector< SgDeclarationStatement * > sortSgNodeListBasedOnAppearanceOrderInSource(const std::vector< SgDeclarationStatement * > &nodevec)
Reorder a list of declaration statements based on their appearance order in source files.
ROSE_DLL_API SgScopeStatement * getEnclosingScope(SgNode *n, const bool includingSelf=false)
Get the enclosing scope from a node n.
ROSE_DLL_API std::string mangleModifierType(SgModifierType *type)
Generated mangled modifier types, include const, volatile,according to Itanium C++ ABI,...
ROSE_DLL_API LivenessAnalysis * call_liveness_analysis(SgProject *project, bool debug=false)
Call liveness analysis on an entire project.
SgFunctionDeclaration * getDeclarationOfNamedFunction(SgExpression *func)
Given a SgExpression that represents a named function (or bound member function), return the mentione...
ROSE_DLL_API std::string mangleType(SgType *type)
Generate a mangled string for a given type based on Itanium C++ ABI.
ROSE_DLL_API SgSwitchStatement * findEnclosingSwitch(SgStatement *s)
Find the closest switch outside a given statement (normally used for case and default statements)
ROSE_DLL_API void fixNamespaceDeclaration(SgNamespaceDeclarationStatement *structDecl, SgScopeStatement *scope)
Fix symbols, parent and scope pointers. Used internally within appendStatment(), insertStatement() et...
ROSE_DLL_API bool addDefaultConstructorIfRequired(SgClassType *classType, int physical_file_id=Sg_File_Info::TRANSFORMATION_FILE_ID)
Get the default destructor from the class declaration.
ROSE_DLL_API SgType * getElementType(SgType *t)
Get the element type of an array, pointer or string, or NULL if not applicable. This function only ch...
ROSE_DLL_API void appendStatementWithDependentDeclaration(SgDeclarationStatement *decl, SgGlobal *scope, SgStatement *original_statement, bool excludeHeaderFiles)
Append a copy ('decl') of a function ('original_statement') into a 'scope', include any referenced de...