ROSE  0.9.9.139
sageInterface.h
1 #ifndef ROSE_SAGE_INTERFACE
2 #define ROSE_SAGE_INTERFACE
3 
4 #include "sage3basic.hhh"
5 #include <stdint.h>
6 #include <utility>
7 
8 #include "rosePublicConfig.h" // for ROSE_BUILD_JAVA_LANGUAGE_SUPPORT
9 #include "OmpAttribute.h"
10 
11 
12 #if 0 // FMZ(07/07/2010): the argument "nextErrorCode" should be call-by-reference
13 SgFile* determineFileType ( std::vector<std::string> argv, int nextErrorCode, SgProject* project );
14 #else
15 SgFile* determineFileType ( std::vector<std::string> argv, int& nextErrorCode, SgProject* project );
16 #endif
17 
18 #ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
19 #include "rewrite.h"
20 #endif
21 
22 // DQ (7/20/2008): Added support for unparsing abitrary strings in the unparser.
23 #include "astUnparseAttribute.h"
24 #include <set>
25 
26 #ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
27 #include "LivenessAnalysis.h"
28 #include "abstract_handle.h"
29 #include "ClassHierarchyGraph.h"
30 #endif
31 
32 // DQ (8/19/2004): Moved from ROSE/src/midend/astRewriteMechanism/rewrite.h
34 ROSE_DLL_API std::string getVariantName (VariantT v);
35 
36 // DQ (12/9/2004): Qing, Rich and Dan have decided to start this namespace within ROSE
37 // This namespace is specific to interface functions that operate on the Sage III AST.
38 // The name was chosen so as not to conflict with other classes within ROSE.
39 // This will become the future home of many interface functions which operate on
40 // the AST and which are generally useful to users. As a namespace multiple files can be used
41 // to represent the compete interface and different developers may contribute interface
42 // functions easily.
43 
44 // Constructor handling: (We have sageBuilder.h now for this purpose, Liao 2/1/2008)
45 // We could add simpler layers of support for construction of IR nodes by
46 // hiding many details in "makeSg***()" functions. Such functions would
47 // return pointers to the associated Sg*** objects and would be able to hide
48 // many IR specific details, including:
49 // memory handling
50 // optional parameter settings not often required
51 // use of Sg_File_Info objects (and setting them as transformations)
52 //
53 // namespace AST_Interface (this name is taken already by some of Qing's work :-)
54 
56 #define TRANS_FILE Sg_File_Info::generateDefaultFileInfoForTransformationNode()
57 
58 
64 namespace SageInterface
65  {
66  // Liao 6/22/2016: keep records of loop init-stmt normalization, later help undo it to support autoPar.
68  {
69  // a lookup table to check if a for loop has been normalized for its c99-style init-stmt
70  std::map <SgForStatement* , bool > forLoopInitNormalizationTable;
71  // Detailed record about the original declaration (1st in the pair) and the normalization generated new declaration (2nd in the pair)
72  std::map <SgForStatement* , std::pair<SgVariableDeclaration*, SgVariableDeclaration*> > forLoopInitNormalizationRecord;
73  } ;
74 
75  ROSE_DLL_API extern Transformation_Record trans_records;
76 
77  // DQ (4/3/2014): Added general AST support separate from the AST.
78 
79  // Container and API for analysis information that is outside of the AST and as a result
80  // prevents frequent modification of the IR.
82  {
83  // DQ (4/3/2014): This stores all associated declarations as a map of sets.
84  // the key to the map is the first nondefining declaration and the elements of the set are
85  // all of the associated declarations (including the defining declaration).
86 
87  private:
89  std::map<SgDeclarationStatement*,std::set<SgDeclarationStatement*>* > declarationMap;
90 
91  public:
92  void addDeclaration(SgDeclarationStatement* decl);
93  const std::set<SgDeclarationStatement*>* getDeclarations(SgDeclarationStatement* decl);
94 
95  std::map<SgDeclarationStatement*,std::set<SgDeclarationStatement*>* > & getDeclarationMap();
96 
97  bool isLocatedInDefiningScope(SgDeclarationStatement* decl);
98 
99  };
100 
101  // DQ (4/3/2014): This constructs a data structure that holds analysis information about
102  // the AST that is separate from the AST. This is intended to be a general mechanism
103  // to support analysis information without constantly modifying the IR.
104  DeclarationSets* buildDeclarationSets(SgNode*);
105 
107 ROSE_DLL_API extern int gensym_counter;
108 
109 // tps : 28 Oct 2008 - support for finding the main interpretation
110  SgAsmInterpretation* getMainInterpretation(SgAsmGenericFile* file);
111 
114 
117 
119  void addMessageStatement( SgStatement* stmt, std::string message );
120 
122  class UniqueNameAttribute : public AstAttribute
123  {
124  private:
125  std::string name;
126  public:
127  UniqueNameAttribute(std::string n="") {name =n; };
128  void set_name (std::string n) {name = n;};
129  std::string get_name () {return name;};
130  };
131 
132 // DQ (3/2/2009): Added support for collectiong an merging the referenced symbols in the outlined
133 // function into the list used to edit the outlined code subtree to fixup references (from symbols
134 // in the original file to the symbols in the newer separate file).
135 // typedef rose_hash::unordered_map<SgNode*, SgNode*, hash_nodeptr> ReplacementMapType;
136 // void supplementReplacementSymbolMap ( const ReplacementMapTraversal::ReplacementMapType & inputReplacementMap );
137 
138 // CH (4/9/2010): Use boost::hash instead
139 //#ifdef _MSC_VER
140 #if 0
141 inline size_t hash_value(SgNode* t) {return (size_t)t;}
142 #endif
143 
144 #if 0
145 // DQ (8/3/2015): We expect that this is not used and is generating a warnings so we
146 // can best fix it by removing it.
147 struct hash_nodeptr
148  {
149 // CH (4/9/2010): Use boost::hash instead
150 //#ifndef _MSC_VER
151 #if 0
152  //rose_hash::hash<char*> hasher;
153 #endif
154  public:
155  size_t operator()(SgNode* node) const
156  {
157 // CH (4/9/2010): Use boost::hash instead
158 //#ifdef _MSC_VER
159  #if 0
160  return (size_t) hash_value(node);
161  #else
162  return (size_t) node;
163  #endif
164  }
165  };
166 
167 #ifndef SWIG
168 // DQ (3/10/2013): This appears to be a problem for the SWIG interface (undefined reference at link-time).
169  void supplementReplacementSymbolMap ( rose_hash::unordered_map<SgNode*, SgNode*, hash_nodeptr> & inputReplacementMap );
170 #endif
171 #endif
172 
173  //------------------------------------------------------------------------
175 
178  // Liao 1/22/2008, used for get symbols for generating variable reference nodes
179  // ! Find a variable symbol in current and ancestor scopes for a given name
180  ROSE_DLL_API SgVariableSymbol *lookupVariableSymbolInParentScopes (const SgName & name, SgScopeStatement *currentScope=NULL);
181 
182 // DQ (8/21/2013): Modified to make newest function parameters be default arguments.
183 // DQ (8/16/2013): For now we want to remove the use of default parameters and add the support for template parameters and template arguments.
185 // SgSymbol *lookupSymbolInParentScopes (const SgName & name, SgScopeStatement *currentScope=NULL);
186 // SgSymbol *lookupSymbolInParentScopes (const SgName & name, SgScopeStatement *currentScope, SgTemplateParameterPtrList* templateParameterList, SgTemplateArgumentPtrList* templateArgumentList);
187  ROSE_DLL_API SgSymbol *lookupSymbolInParentScopes (const SgName & name, SgScopeStatement *currentScope = NULL, SgTemplateParameterPtrList* templateParameterList = NULL, SgTemplateArgumentPtrList* templateArgumentList = NULL);
188 
189  // DQ (11/24/2007): Functions moved from the Fortran support so that they could be called from within astPostProcessing.
191  ROSE_DLL_API SgFunctionSymbol *lookupFunctionSymbolInParentScopes (const SgName & functionName, SgScopeStatement *currentScope=NULL);
192 
193  // Liao, 1/24/2008, find exact match for a function
195  ROSE_DLL_API SgFunctionSymbol *lookupFunctionSymbolInParentScopes (const SgName & functionName,
196  const SgType* t,
197  SgScopeStatement *currentScope=NULL);
198 
199 // DQ (8/21/2013): Modified to make newest function parameters be default arguments.
200 // DQ (8/16/2013): For now we want to remove the use of default parameters and add the support for template parameters and template arguments.
201 // DQ (5/7/2011): Added support for SgClassSymbol (used in name qualification support).
202 // SgClassSymbol* lookupClassSymbolInParentScopes (const SgName & name, SgScopeStatement *currentScope = NULL);
203  ROSE_DLL_API SgClassSymbol* lookupClassSymbolInParentScopes (const SgName & name, SgScopeStatement *currentScope = NULL, SgTemplateArgumentPtrList* templateArgumentList = NULL);
204  ROSE_DLL_API SgTypedefSymbol* lookupTypedefSymbolInParentScopes (const SgName & name, SgScopeStatement *currentScope = NULL);
205 
206 #if 0
207  // DQ (8/13/2013): This function does not make since any more, now that we have made the symbol
208  // table handling more precise and we have to provide template parameters for any template lookup.
209  // We also have to know if we want to lookup template classes, template functions, or template
210  // member functions (since each have specific requirements).
211  SgTemplateSymbol* lookupTemplateSymbolInParentScopes (const SgName & name, SgScopeStatement *currentScope = NULL);
212 #endif
213 #if 0
214 // DQ (8/13/2013): I am not sure if we want this functions in place of lookupTemplateSymbolInParentScopes.
215 // Where these are called we might not know enough information about the template parameters or function
216 // types, for example.
217  SgTemplateClassSymbol* lookupTemplateClassSymbolInParentScopes (const SgName & name, SgScopeStatement *currentScope = NULL, SgTemplateParameterPtrList* templateParameterList = NULL, SgTemplateArgumentPtrList* templateArgumentList = NULL);
218  SgTemplateFunctionSymbol* lookupTemplateFunctionSymbolInParentScopes (const SgName & name, SgScopeStatement *currentScope = NULL, SgTemplateParameterPtrList* templateParameterList = NULL);
219  SgTemplateMemberFunctionSymbol* lookupTemplateMemberFunctionSymbolInParentScopes (const SgName & name, SgScopeStatement *currentScope = NULL, SgTemplateParameterPtrList* templateParameterList = NULL);
220 #endif
221 
222 // DQ (8/21/2013): Modified to make some of the newest function parameters be default arguments.
223 // DQ (8/13/2013): I am not sure if we want this functions in place of lookupTemplateSymbolInParentScopes.
224  ROSE_DLL_API SgTemplateClassSymbol* lookupTemplateClassSymbolInParentScopes (const SgName & name, SgTemplateParameterPtrList* templateParameterList, SgTemplateArgumentPtrList* templateArgumentList, SgScopeStatement *cscope = NULL);
225 
226  ROSE_DLL_API SgEnumSymbol* lookupEnumSymbolInParentScopes (const SgName & name, SgScopeStatement *currentScope = NULL);
227  ROSE_DLL_API SgNamespaceSymbol* lookupNamespaceSymbolInParentScopes(const SgName & name, SgScopeStatement *currentScope = NULL);
228 
229 // DQ (7/17/2011): Added function from cxx branch that I need here for the Java support.
230 // SgClassSymbol* lookupClassSymbolInParentScopes (const SgName & name, SgScopeStatement *cscope);
231 
240  // DQ (12/9/2004): Moved this function (by Alin Jula) from being a member of SgInitializedName
241  // to this location where it can be a part of the interface for the Sage III AST.
242  ROSE_DLL_API int set_name (SgInitializedName * initializedNameNode, SgName new_name);
243 
247 
248  // DQ (6/27/2005):
253  ROSE_DLL_API void outputLocalSymbolTables (SgNode * node);
254 
256  {
257  public:
258  void visit (SgNode * node);
259  };
265  // DQ (9/28/2005):
266  void rebuildSymbolTable (SgScopeStatement * scope);
267 
270  void clearUnusedVariableSymbols (SgNode* root = NULL);
271 
272  // DQ (3/1/2009):
274  void fixupReferencesToSymbols( const SgScopeStatement* this_scope, SgScopeStatement* copy_scope, SgCopyHelp & help );
275 
277 
278  //------------------------------------------------------------------------
280 
287  // DQ (9/21/2005): General function for extracting the name of declarations (when they have names)
288  std::string get_name (const SgNode * node);
289 
294  // DQ (6/13/2005): General function for extracting the name of declarations (when they have names)
295  std::string get_name (const SgStatement * stmt);
296 
301  std::string get_name (const SgExpression * expr);
302 
307  // DQ (6/13/2005): General function for extracting the name of declarations (when they have names)
308  std::string get_name (const SgDeclarationStatement * declaration);
309 
314  // DQ (6/13/2005): General function for extracting the name of declarations (when they have names)
315  std::string get_name (const SgScopeStatement * scope);
316 
321  // DQ (2/11/2007): Added this function to make debugging support more complete (useful for symbol table debugging support).
322  std::string get_name (const SgSymbol * symbol);
323 
328  std::string get_name (const SgType * type);
329 
330 
333  std::string get_name (const SgSupport * node);
334 
335 
338  std::string get_name (const SgLocatedNodeSupport * node);
339 
342  std::string get_name ( const SgC_PreprocessorDirectiveStatement* directive );
343 
346  std::string get_name ( const SgToken* token );
347 
348  // DQ (3/20/2016): Added to refactor some of the DSL infrastructure support.
358 
361  extern std::map<std::string,int> local_name_collision_map;
362  extern std::map<std::string,SgNode*> local_name_to_node_map;
363  extern std::map<SgNode*,std::string> local_node_to_name_map;
364 
368 
372 
374 
375  //------------------------------------------------------------------------
377 
382  // DQ (6/21/2005): Get the default destructor from the class declaration
384  classDeclaration);
385 
388  // DQ (6/22/2005): Get the default constructor from the class declaration
390  classDeclaration);
393  // DQ (8/27/2005):
395  * memberFunctionDeclaration);
396 
401  // DQ (9/17/2005):
404  (SgTemplateInstantiationMemberFunctionDecl * memberFunctionInstantiation);
405 
407  bool isStructDeclaration(SgNode * node);
409  bool isUnionDeclaration(SgNode * node);
410  #if 0
411  // DQ (8/28/2005): This is already a member function of the SgFunctionDeclaration
412  // (so that it can handle template functions and member functions)
413 
417  // DQ (8/27/2005):
418  bool isTemplateMemberFunction (SgTemplateInstantiationMemberFunctionDecl *
419  memberFunctionDeclaration);
420  #endif
421 
423 
424  //------------------------------------------------------------------------
426 
430  void saveToPDF(SgNode* node, std::string filename);
432  void saveToPDF(SgNode* node); // enable calling from gdb
433 
434  // DQ (2/12/2012): Added some diagnostic support.
436  void whereAmI(SgNode* node);
437 
439  std::string extractPragmaKeyword(const SgPragmaDeclaration *);
440 
442  ROSE_DLL_API bool isOmpStatement(SgNode* );
445  // DQ (8/27/2005):
446  bool isOverloaded (SgFunctionDeclaration * functionDeclaration);
447 
448 // DQ (2/14/2012): Added support function used for variable declarations in conditionals.
450  void initializeIfStmt(SgIfStmt *ifstmt, SgStatement* conditional, SgStatement * true_body, SgStatement * false_body);
451 
453  void initializeSwitchStatement(SgSwitchStatement* switchStatement,SgStatement *item_selector,SgStatement *body);
454 
456  void initializeWhileStatement(SgWhileStmt* whileStatement, SgStatement * condition, SgStatement *body, SgStatement *else_body);
457 
460 
462  ROSE_DLL_API bool isMain (const SgNode* node);
463  // DQ (6/22/2005):
474  std::string generateUniqueName ( const SgNode * node, bool ignoreDifferenceBetweenDefiningAndNondefiningDeclarations);
475 
478  std::string generateUniqueVariableName(SgScopeStatement* scope, std::string baseName = "temp");
479 
480  // DQ (8/10/2010): Added const to first parameter.
481  // DQ (3/10/2007):
483  std::string declarationPositionString (const SgDeclarationStatement * declaration);
484 
485  // DQ (1/20/2007):
487  ROSE_DLL_API std::string generateProjectName (const SgProject * project, bool supressSuffix = false );
488 
492 
495 
497  void addVarRefExpFromArrayDimInfo(SgNode * astNode, Rose_STL_Container<SgNode *>& NodeList_t);
498 
499  // DQ (10/6/2006): Added support for faster mangled name generation (caching avoids recomputation).
503 #ifndef SWIG
504 // DQ (3/10/2013): This appears to be a problem for the SWIG interface (undefined reference at link-time).
505  void clearMangledNameCache (SgGlobal * globalScope);
506  void resetMangledNameCache (SgGlobal * globalScope);
507 #endif
508 
509  std::string getMangledNameFromCache (SgNode * astNode);
510  std::string addMangledNameToCache (SgNode * astNode, const std::string & mangledName);
511 
513 
517 
518  // DQ (10/14/2006): This function tests the AST to see if for a non-defining declaration, the
519  // bool declarationPreceedsDefinition ( SgClassDeclaration* classNonDefiningDeclaration, SgClassDeclaration* classDefiningDeclaration );
521  bool declarationPreceedsDefinition (SgDeclarationStatement *nonDefiningDeclaration, SgDeclarationStatement *definingDeclaration);
522 
523  // DQ (10/19/2006): Function calls have interesting context dependent rules to determine if
524  // they are output with a global qualifier or not. Were this is true we have to avoid global
525  // qualifiers, since the function's scope has not been defined. This is an example of where
526  // qualification of function names in function calls are context dependent; an interesting
527  // example of where the C++ language is not friendly to source-to-source processing :-).
529 
534  ROSE_DLL_API std::vector < SgNode * >astIntersection (SgNode * original, SgNode * copy, SgCopyHelp * help = NULL);
535 
537  ROSE_DLL_API SgNode* deepCopyNode (const SgNode* subtree);
538 
540  template <typename NodeType>
541  NodeType* deepCopy (const NodeType* subtree) {
542  return dynamic_cast<NodeType*>(deepCopyNode(subtree));
543  }
544 
546  ROSE_DLL_API SgExpression* copyExpression(SgExpression* e);
547 
549  ROSE_DLL_API SgStatement* copyStatement(SgStatement* s);
550 
551 // from VarSym.cc in src/midend/astOutlining/src/ASTtools
554 
557 
559 ROSE_DLL_API void myRemoveStatement(SgStatement* stmt);
560 
561 ROSE_DLL_API bool isConstantTrue(SgExpression* e);
562 ROSE_DLL_API bool isConstantFalse(SgExpression* e);
563 
565 ROSE_DLL_API bool isCallToParticularFunction(const std::string& qualifiedName, size_t arity, SgExpression* e);
566 
568 bool ROSE_DLL_API isStatic(SgDeclarationStatement* stmt);
569 
571 ROSE_DLL_API void setStatic(SgDeclarationStatement* stmt);
572 
574 ROSE_DLL_API bool isExtern(SgDeclarationStatement* stmt);
575 
577 ROSE_DLL_API void setExtern(SgDeclarationStatement* stmt);
578 
582  public:
583  virtual ~StatementGenerator() {};
584  virtual SgStatement* generate(SgExpression* where_to_write_answer) = 0;
585 };
586 
590  bool isAssignmentStatement(SgNode* _s, SgExpression** lhs=NULL, SgExpression** rhs=NULL, bool* readlhs=NULL);
591 
593 ROSE_DLL_API SgInitializedName* convertRefToInitializedName(SgNode* current, bool coarseGrain=true);
594 
597 
599 ROSE_DLL_API SgNode* getSgNodeFromAbstractHandleString(const std::string& input_string);
600 
602 ROSE_DLL_API void dumpInfo(SgNode* node, std::string desc="");
603 
605 ROSE_DLL_API std::vector<SgDeclarationStatement*>
606 sortSgNodeListBasedOnAppearanceOrderInSource(const std::vector<SgDeclarationStatement*>& nodevec);
607 
608 // DQ (4/13/2013): We need these to support the unparing of operators defined by operator syntax or member function names.
610 // bool isPrefixOperator( const SgMemberFunctionRefExp* memberFunctionRefExp );
611 bool isPrefixOperator( SgExpression* exp );
612 
614 bool isPrefixOperatorName( const SgName & functionName );
615 
617 bool isPostfixOperator( SgExpression* exp );
618 
620 bool isIndexOperator( SgExpression* exp );
621 
622 // DQ (1/10/2014): Adding more general support for token based unparsing.
624 SgStatement* lastStatementOfScopeWithTokenInfo (SgScopeStatement* scope, std::map<SgNode*,TokenStreamSequenceToNodeMapping*> & tokenStreamSequenceMap);
625 
627 
628 //------------------------------------------------------------------------
630 
634 // std::string version(); // utility_functions.h, version number
637  ROSE_DLL_API bool is_C_language ();
638  ROSE_DLL_API bool is_OpenMP_language ();
639  ROSE_DLL_API bool is_UPC_language ();
641  ROSE_DLL_API bool is_UPC_dynamic_threads();
642  ROSE_DLL_API bool is_C99_language ();
643  ROSE_DLL_API bool is_Cxx_language ();
644  ROSE_DLL_API bool is_Java_language ();
645  ROSE_DLL_API bool is_Fortran_language ();
646  ROSE_DLL_API bool is_CAF_language ();
647  ROSE_DLL_API bool is_PHP_language();
648  ROSE_DLL_API bool is_Python_language();
649  ROSE_DLL_API bool is_Cuda_language();
650  ROSE_DLL_API bool is_OpenCL_language();
651  ROSE_DLL_API bool is_X10_language();
652  ROSE_DLL_API bool is_binary_executable();
653  ROSE_DLL_API bool is_mixed_C_and_Cxx_language ();
654  ROSE_DLL_API bool is_mixed_Fortran_and_C_language ();
655  ROSE_DLL_API bool is_mixed_Fortran_and_Cxx_language ();
656  ROSE_DLL_API bool is_mixed_Fortran_and_C_and_Cxx_language ();
658 
659 //------------------------------------------------------------------------
661 
665  // DQ (10/5/2006): Added support for faster (non-quadratic) computation of unique
666  // labels for scopes in a function (as required for name mangling).
672  void resetScopeNumbers (SgFunctionDefinition * functionDeclaration);
673 
674  // DQ (10/5/2006): Added support for faster (non-quadratic) computation of unique
675  // labels for scopes in a function (as required for name mangling).
684  void clearScopeNumbers (SgFunctionDefinition * functionDefinition);
685 
686 
689 // SgNamespaceDefinitionStatement * getEnclosingNamespaceScope (SgNode * node);
690 
691  bool isPrototypeInScope (SgScopeStatement * scope,
692  SgFunctionDeclaration * functionDeclaration,
693  SgDeclarationStatement * startingAtDeclaration);
694 
696  bool ROSE_DLL_API isAncestor(SgNode* node1, SgNode* node2);
698 //------------------------------------------------------------------------
700 
704  void dumpPreprocInfo (SgLocatedNode* locatedNode);
706 
708 PreprocessingInfo * insertHeader(SgSourceFile * source_file, const std::string & header_file_name, bool isSystemHeader, bool asLastHeader);
709 
711 void insertHeader (SgStatement* stmt, PreprocessingInfo* newheader, bool asLastHeader);
712 
714 PreprocessingInfo * insertHeader(SgSourceFile * source_file, const std::string & header_file_name, bool isSystemHeader = false, PreprocessingInfo::RelativePositionType position = PreprocessingInfo::before);
715 
717 ROSE_DLL_API PreprocessingInfo* insertHeader(const std::string& filename, PreprocessingInfo::RelativePositionType position=PreprocessingInfo::after, bool isSystemHeader=false, SgScopeStatement* scope=NULL);
718 
720 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);
721 
723 ROSE_DLL_API void movePreprocessingInfo (SgStatement* stmt_src, SgStatement* stmt_dst, PreprocessingInfo::RelativePositionType src_position=PreprocessingInfo::undef,
724  PreprocessingInfo::RelativePositionType dst_position=PreprocessingInfo::undef, bool usePrepend= false);
725 
726 
728 ROSE_DLL_API void cutPreprocessingInfo (SgLocatedNode* src_node, PreprocessingInfo::RelativePositionType pos, AttachedPreprocessingInfoType& save_buf);
729 
731 ROSE_DLL_API void pastePreprocessingInfo (SgLocatedNode* dst_node, PreprocessingInfo::RelativePositionType pos, AttachedPreprocessingInfoType& saved_buf);
732 
735  const std::string & text,
736  PreprocessingInfo::RelativePositionType position=PreprocessingInfo::before);
737 
741 
744  SgSourceFile * source_file,
745  const std::string & content,
746  PreprocessingInfo::DirectiveType directive_type = PreprocessingInfo::C_StyleComment,
747  PreprocessingInfo::RelativePositionType position = PreprocessingInfo::before
748 );
749 
751  ROSE_DLL_API PreprocessingInfo* attachComment(SgLocatedNode* target, const std::string & content,
752  PreprocessingInfo::RelativePositionType position=PreprocessingInfo::before,
753  PreprocessingInfo::DirectiveType dtype= PreprocessingInfo::CpreprocessorUnknownDeclaration);
754 
755 // DQ (11/25/2009): Added matching support for adding comments to SgAsm nodes.
756 // Build and attach comment
757 // void attachComment(SgAsmStatement* target, const std::string & content );
758 
759 // DQ (7/20/2008): I am not clear were I should put this function, candidates include: SgLocatedNode or SgInterface
761  ROSE_DLL_API void addTextForUnparser ( SgNode* astNode, std::string s, AstUnparseAttribute::RelativePositionType inputlocation );
762 
767 void guardNode(SgLocatedNode * target, std::string guard);
768 
770 
771 
772 //------------------------------------------------------------------------
774 
778 // ************************************************************************
779 // Newer versions of now depricated functions
780 // ************************************************************************
781 
782 // DQ (5/1/2012): This function queries the SageBuilder::SourcePositionClassification mode (stored in the SageBuilder
783 // interface) and used the specified mode to initialize the source position data (Sg_File_Info objects). This
784 // function is the only function that should be called directly (though in a namespace we can't define permissions).
786  ROSE_DLL_API void setSourcePosition(SgNode* node);
787 
788 // A better name might be "setSourcePositionForSubTree"
790  ROSE_DLL_API void setSourcePositionAtRootAndAllChildren(SgNode *root);
791 
794 
795 // DQ (5/1/2012): Newly renamed function (previous name preserved for backward compatability).
797 
798 // ************************************************************************
799 
800 
801 
802 // ************************************************************************
803 // Older deprecated functions
804 // ************************************************************************
805  // Liao, 1/8/2007, set file info. for a whole subtree as transformation generated
807  ROSE_DLL_API void setOneSourcePositionForTransformation(SgNode *node);
808 
810  ROSE_DLL_API void setOneSourcePositionNull(SgNode *node);
811 
813  ROSE_DLL_API void setSourcePositionForTransformation (SgNode * root);
814 
816 // ROSE_DLL_API void setSourcePositionForTransformation_memoryPool();
817 
819  ROSE_DLL_API bool insideSystemHeader (SgLocatedNode* node);
820 
822 // ROSE_DLL_API void setSourcePosition (SgLocatedNode * locatedNode);
823 // ************************************************************************
824 
826 
827 
828 //------------------------------------------------------------------------
830 
834 // from src/midend/astInlining/typeTraits.h
835 // src/midend/astUtil/astInterface/AstInterface.h
836 
839 
840 
844 ROSE_DLL_API bool isStrictIntegerType(SgType* t);
846 ROSE_DLL_API SgType* getFirstVarType(SgVariableDeclaration* decl);
847 
849 ROSE_DLL_API bool isDefaultConstructible(SgType* type);
850 
852 ROSE_DLL_API bool isCopyConstructible(SgType* type);
853 
855 ROSE_DLL_API bool isAssignable(SgType* type);
856 
857 #ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
858 ROSE_DLL_API bool isPureVirtualClass(SgType* type, const ClassHierarchyWrapper& classHierarchy);
862 #endif
863 
865 ROSE_DLL_API bool hasTrivialDestructor(SgType* t);
866 
868 ROSE_DLL_API bool isNonconstReference(SgType* t);
869 
871 ROSE_DLL_API bool isReferenceType(SgType* t);
872 
874 ROSE_DLL_API bool isPointerType(SgType* t);
875 
881 ROSE_DLL_API bool isPointerToNonConstType(SgType* type);
882 
884 /* const char* p = "aa"; is not treated as having a const type. It is a pointer to const char.
885  * Similarly, neither for const int b[10]; or const int & c =10;
886  * The standard says, "A compound type is not cv-qualified by the cv-qualifiers (if any) of
887 the types from which it is compounded. Any cv-qualifiers applied to an array type affect the array element type, not the array type".
888  */
889 ROSE_DLL_API bool isConstType(SgType* t);
890 
893 
895 ROSE_DLL_API bool isVolatileType(SgType* t);
896 
898 ROSE_DLL_API bool isRestrictType(SgType* t);
899 
901 
903 ROSE_DLL_API bool isScalarType(SgType* t);
904 
908 ROSE_DLL_API bool isStrictIntegerType(SgType* t);
909 
911 ROSE_DLL_API bool isStructType(SgType* t);
912 
914 ROSE_DLL_API std::string mangleType(SgType* type);
915 
917 ROSE_DLL_API std::string mangleScalarType(SgType* type);
918 
920 ROSE_DLL_API std::string mangleModifierType(SgModifierType* type);
921 
923 ROSE_DLL_API size_t getArrayElementCount(SgArrayType* t);
924 
926 ROSE_DLL_API int getDimensionCount(SgType* t);
927 
929 ROSE_DLL_API SgType* getArrayElementType(SgType* t);
930 
932 ROSE_DLL_API SgType* getElementType(SgType* t);
933 
934 
951 std::vector<SgExpression*>
952 get_C_array_dimensions(const SgArrayType& arrtype);
953 
974 std::vector<SgExpression*>
975 get_C_array_dimensions(const SgArrayType& arrtype, const SgVarRefExp& varref);
976 
980 std::vector<SgExpression*>
981 get_C_array_dimensions(const SgArrayType& arrtype, SgInitializedName& initname);
982 
983 
985 ROSE_DLL_API bool isArrayReference(SgExpression* ref, SgExpression** arrayNameExp=NULL, std::vector<SgExpression*>** subscripts=NULL);
986 
987 
989 ROSE_DLL_API int collectVariableReferencesInArrayTypes (SgLocatedNode* root, Rose_STL_Container<SgNode*> & currentVarRefList);
991 
1000 ROSE_DLL_API bool hasUpcSharedType(SgType* t, SgModifierType ** mod_type_out = NULL );
1001 
1003 
1006 ROSE_DLL_API bool isUpcSharedType(SgType* t, SgModifierType ** mod_type_out = NULL);
1007 
1009 ROSE_DLL_API bool isUpcSharedModifierType (SgModifierType* mod_type);
1010 
1012 ROSE_DLL_API bool isUpcSharedArrayType (SgArrayType* array_type);
1013 
1015 ROSE_DLL_API bool isUpcStrictSharedModifierType(SgModifierType* mode_type);
1016 
1018 ROSE_DLL_API size_t getUpcSharedBlockSize(SgModifierType* mod_type);
1019 
1021 ROSE_DLL_API size_t getUpcSharedBlockSize(SgType* t);
1022 
1024 ROSE_DLL_API bool isUpcPhaseLessSharedType (SgType* t);
1025 
1027 ROSE_DLL_API bool isUpcPrivateToSharedType(SgType* t);
1028 
1030 ROSE_DLL_API bool isUpcArrayWithThreads(SgArrayType* t);
1031 
1033 ROSE_DLL_API SgType* lookupNamedTypeInParentScopes(const std::string& type_name, SgScopeStatement* scope=NULL);
1034 
1035 // DQ (7/22/2014): Added support for comparing expression types in actual arguments with those expected from the formal function parameter types.
1037 ROSE_DLL_API SgType* getAssociatedTypeFromFunctionTypeList(SgExpression* actual_argument_expression);
1038 
1040 ROSE_DLL_API bool templateArgumentEquivalence(SgTemplateArgument * arg1, SgTemplateArgument * arg2);
1041 
1043 ROSE_DLL_API bool templateArgumentListEquivalence(const SgTemplateArgumentPtrList & list1, const SgTemplateArgumentPtrList & list2);
1044 
1046 ROSE_DLL_API bool isEquivalentType (const SgType* lhs, const SgType* rhs);
1047 
1048 
1051 ROSE_DLL_API bool isEquivalentFunctionType (const SgFunctionType* lhs, const SgFunctionType* rhs);
1052 
1054 
1055 //------------------------------------------------------------------------
1057 
1061 // by Jeremiah
1070 ROSE_DLL_API void addStepToLoopBody(SgScopeStatement* loopStmt, SgStatement* step);
1071 
1073 ROSE_DLL_API void convertForToWhile(SgForStatement* f);
1074 ROSE_DLL_API void convertAllForsToWhiles(SgNode* top);
1076 ROSE_DLL_API void changeContinuesToGotos(SgStatement* stmt, SgLabelStatement* label);
1077 
1079 ROSE_DLL_API SgInitializedName* getLoopIndexVariable(SgNode* loop);
1080 
1083 ROSE_DLL_API bool isLoopIndexVariable(SgInitializedName* ivar, SgNode* subtree_root);
1084 
1086 
1090 ROSE_DLL_API bool hasMultipleInitStatmentsOrExpressions (SgForStatement* for_loop);
1091 
1093 ROSE_DLL_API SgStatement* getLoopBody(SgScopeStatement* loop);
1094 
1095 ROSE_DLL_API void setLoopBody(SgScopeStatement* loop, SgStatement* body);
1096 
1098 ROSE_DLL_API SgStatement* getLoopCondition(SgScopeStatement* loop);
1099 
1101 ROSE_DLL_API void setLoopCondition(SgScopeStatement* loop, SgStatement* cond);
1102 
1106 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);
1107 
1109 ROSE_DLL_API bool isCanonicalDoLoop(SgFortranDo* loop,SgInitializedName** ivar/*=NULL*/, SgExpression** lb/*=NULL*/, SgExpression** ub/*=NULL*/, SgExpression** step/*=NULL*/, SgStatement** body/*=NULL*/, bool *hasIncrementalIterationSpace/*= NULL*/, bool* isInclusiveUpperBound/*=NULL*/);
1110 
1112 ROSE_DLL_API void setLoopLowerBound(SgNode* loop, SgExpression* lb);
1113 
1115 ROSE_DLL_API void setLoopUpperBound(SgNode* loop, SgExpression* ub);
1116 
1118 ROSE_DLL_API void setLoopStride(SgNode* loop, SgExpression* stride);
1119 
1120 
1122 ROSE_DLL_API bool normalizeForLoopInitDeclaration(SgForStatement* loop);
1123 
1125 ROSE_DLL_API bool unnormalizeForLoopInitDeclaration(SgForStatement* loop);
1126 
1138 ROSE_DLL_API bool forLoopNormalization(SgForStatement* loop, bool foldConstant = true);
1139 
1143 ROSE_DLL_API bool normalizeForLoopTest(SgForStatement* loop);
1144 ROSE_DLL_API bool normalizeForLoopIncrement(SgForStatement* loop);
1145 
1147 ROSE_DLL_API bool doLoopNormalization(SgFortranDo* loop);
1148 
1150 ROSE_DLL_API bool loopUnrolling(SgForStatement* loop, size_t unrolling_factor);
1151 
1153 ROSE_DLL_API bool loopInterchange(SgForStatement* loop, size_t depth, size_t lexicoOrder);
1154 
1156 ROSE_DLL_API bool loopTiling(SgForStatement* loopNest, size_t targetLevel, size_t tileSize);
1157 
1158 //Winnie Loop Collapsing
1159 SgExprListExp * loopCollapsing(SgForStatement* target_loop, size_t collapsing_factor);
1160 
1162  SgForStatement * for_loop,
1163  SgVariableSymbol * & iterator,
1164  SgExpression * & lower_bound,
1165  SgExpression * & upper_bound,
1166  SgExpression * & stride
1167 );
1168 
1170 
1171 //------------------------------------------------------------------------
1173 
1177 template <typename NodeType>
1179 std::vector<NodeType*> querySubTree(SgNode* top, VariantT variant = (VariantT)NodeType::static_variant)
1180 {
1181  Rose_STL_Container<SgNode*> nodes = NodeQuery::querySubTree(top,variant);
1182  std::vector<NodeType*> result(nodes.size(), NULL);
1183  int count = 0;
1184  for (Rose_STL_Container<SgNode*>::const_iterator i = nodes.begin();
1185  i != nodes.end(); ++i, ++count) {
1186  NodeType* node = dynamic_cast<NodeType*>(*i);
1187  ROSE_ASSERT (node);
1188  result[count] = node;
1189  }
1190  return result;
1191 }
1196  std::vector < SgFile * >generateFileList ();
1197 
1202 ROSE_DLL_API SgProject * getProject();
1203 
1205  SgProject * getProject(const SgNode * node);
1206 
1208 template <typename NodeType>
1209 static std::vector<NodeType*> getSgNodeListFromMemoryPool()
1210 {
1211  // This function uses a memory pool traversal specific to the SgFile IR nodes
1212  class MyTraversal : public ROSE_VisitTraversal
1213  {
1214  public:
1215  std::vector<NodeType*> resultlist;
1216  void visit ( SgNode* node)
1217  {
1218  NodeType* result = dynamic_cast<NodeType* > (node);
1219  ROSE_ASSERT(result!= NULL);
1220  if (result!= NULL)
1221  {
1222  resultlist.push_back(result);
1223  }
1224  };
1225  virtual ~MyTraversal() {}
1226  };
1227 
1228  MyTraversal my_traversal;
1229  NodeType::traverseMemoryPoolNodes(my_traversal);
1230  return my_traversal.resultlist;
1231 }
1232 
1233 
1236 ROSE_DLL_API SgFunctionDeclaration* findMain(SgNode* currentNode);
1237 
1239 SgStatement* findLastDeclarationStatement(SgScopeStatement * scope, bool includePragma = false);
1240 
1241  //midend/programTransformation/partialRedundancyElimination/pre.h
1243 std::vector<SgVariableSymbol*> getSymbolsUsedInExpression(SgExpression* expr);
1244 
1246 
1251 std::vector<SgBreakStmt*> findBreakStmts(SgStatement* code, const std::string& fortranLabel = "");
1252 
1254 
1259 std::vector<SgContinueStmt*> findContinueStmts(SgStatement* code, const std::string& fortranLabel = "");
1260 std::vector<SgGotoStatement*> findGotoStmts(SgStatement* scope, SgLabelStatement* l);
1261 std::vector<SgStatement*> getSwitchCases(SgSwitchStatement* sw);
1262 
1264 void collectVarRefs(SgLocatedNode* root, std::vector<SgVarRefExp* >& result);
1265 
1267 template <typename T>
1268 T* findDeclarationStatement(SgNode* root, std::string name, SgScopeStatement* scope, bool isDefining)
1269  {
1270  bool found = false;
1271 
1272 #if 0
1273  printf ("In findDeclarationStatement(): root = %p \n",root);
1274  printf ("In findDeclarationStatement(): name = %s \n",name.c_str());
1275  printf ("In findDeclarationStatement(): scope = %p \n",scope);
1276  printf ("In findDeclarationStatement(): isDefining = %s \n",isDefining ? "true" : "false");
1277 #endif
1278 
1279  // Do we really want a NULL pointer to be acceptable input to this function?
1280  // Maybe we should have an assertion that it is non-null?
1281  if (!root) return NULL;
1282 
1283  T* decl = dynamic_cast<T*>(root);
1284 
1285 #if 0
1286  printf ("In findDeclarationStatement(): decl = %p \n",decl);
1287 #endif
1288 
1289  if (decl != NULL)
1290  {
1291  if (scope)
1292  {
1293  if ((decl->get_scope() == scope) && (decl->search_for_symbol_from_symbol_table()->get_name() == name))
1294  {
1295  found = true;
1296  }
1297  }
1298  else // Liao 2/9/2010. We should allow NULL scope
1299  {
1300 #if 0
1301  // DQ (12/6/2016): Include this into the debugging code to aboid compiler warning about unused variable.
1302  SgSymbol* symbol = decl->search_for_symbol_from_symbol_table();
1303  printf ("In findDeclarationStatement(): decl->search_for_symbol_from_symbol_table() = %p \n",symbol);
1304  printf ("In findDeclarationStatement(): decl->search_for_symbol_from_symbol_table()->get_name() = %s \n",symbol->get_name().str());
1305 #endif
1306  if (decl->search_for_symbol_from_symbol_table()->get_name() == name)
1307  {
1308  found = true;
1309  }
1310  }
1311  }
1312 
1313  if (found)
1314  {
1315  if (isDefining)
1316  {
1317 #if 0
1318  printf ("In findDeclarationStatement(): decl->get_firstNondefiningDeclaration() = %p \n",decl->get_firstNondefiningDeclaration());
1319  printf ("In findDeclarationStatement(): decl->get_definingDeclaration() = %p \n",decl->get_definingDeclaration());
1320 #endif
1321  ROSE_ASSERT (decl->get_definingDeclaration() != NULL);
1322 #if 0
1323  printf ("In findDeclarationStatement(): returing decl->get_definingDeclaration() = %p \n",decl->get_definingDeclaration());
1324 #endif
1325  return dynamic_cast<T*> (decl->get_definingDeclaration());
1326  }
1327  else
1328  {
1329 #if 0
1330  printf ("In findDeclarationStatement(): returing decl = %p \n",decl);
1331 #endif
1332  return decl;
1333  }
1334  }
1335 
1336  std::vector<SgNode*> children = root->get_traversalSuccessorContainer();
1337 
1338 #if 0
1339  printf ("In findDeclarationStatement(): children.size() = %zu \n",children.size());
1340 #endif
1341 
1342  // DQ (4/10/2016): Note that if we are searching for a function member that has it's defining
1343  // declaration defined outside of the class then it will not be found in the child list.
1344  for (std::vector<SgNode*>::const_iterator i = children.begin(); i != children.end(); ++i)
1345  {
1346  T* target = findDeclarationStatement<T> (*i,name,scope,isDefining);
1347 
1348  if (target)
1349  {
1350  return target;
1351  }
1352  }
1353 
1354  return NULL;
1355  }
1357  SgFunctionDeclaration* findFunctionDeclaration(SgNode* root, std::string name, SgScopeStatement* scope, bool isDefining);
1358 
1359 #if 0 //TODO
1360  // 1. preorder traversal from current SgNode till find next SgNode of type V_SgXXX
1361  // until reach the end node
1362  SgNode* getNextSgNode( const SgNode* astSourceNode, VariantT=V_SgNode, SgNode* astEndNode=NULL);
1363 
1364  // 2. return all nodes of type VariantT following the source node
1365  std::vector<SgNode*> getAllNextSgNode( const SgNode* astSourceNode, VariantT=V_SgNode, SgNode* astEndNode=NULL);
1366 #endif
1367 
1369 
1370 //------------------------------------------------------------------------
1372 
1375 // remember to put const to all arguments.
1376 
1377 
1392 template <typename NodeType>
1393 NodeType* getEnclosingNode(const SgNode* astNode, const bool includingSelf = false)
1394  {
1395 #if 1
1396  // DQ (10/20/2012): This is the older version of this implementation. Until I am sure that
1397  // the newer version (below) is what we want to use I will resolve this conflict by keeping
1398  // the previous version in place.
1399 
1400  if (NULL == astNode)
1401  {
1402  return NULL;
1403  }
1404 
1405  if ( (includingSelf ) && (dynamic_cast<const NodeType*>(astNode)) )
1406  {
1407  return const_cast<NodeType*>(dynamic_cast<const NodeType*> (astNode));
1408  }
1409 
1410  // DQ (3/5/2012): Check for reference to self...
1411  ROSE_ASSERT(astNode->get_parent() != astNode);
1412 
1413  SgNode* parent = astNode->get_parent();
1414 
1415  // DQ (3/5/2012): Check for loops that will cause infinite loops.
1416  SgNode* previouslySeenParent = parent;
1417  bool foundCycle = false;
1418  while ( (foundCycle == false) && (parent != NULL) && (!dynamic_cast<const NodeType*>(parent)) )
1419  {
1420  ROSE_ASSERT(parent->get_parent() != parent);
1421 #if 0
1422  printf ("In getEnclosingNode(): parent = %p = %s \n",parent,parent->class_name().c_str());
1423 #endif
1424  parent = parent->get_parent();
1425 
1426  // DQ (3/5/2012): Check for loops that will cause infinite loops.
1427  // ROSE_ASSERT(parent != previouslySeenParent);
1428  if (parent == previouslySeenParent)
1429  {
1430  foundCycle = true;
1431  }
1432  }
1433 
1434 #if 0
1435  printf ("previouslySeenParent = %p = %s \n",previouslySeenParent,previouslySeenParent->class_name().c_str());
1436 #endif
1437 
1438  parent = previouslySeenParent;
1439 
1440  SgDeclarationStatement* declarationStatement = isSgDeclarationStatement(parent);
1441  if (declarationStatement != NULL)
1442  {
1443 #if 0
1444  printf ("Found a SgDeclarationStatement \n");
1445 #endif
1446  SgDeclarationStatement* definingDeclaration = declarationStatement->get_definingDeclaration();
1447  SgDeclarationStatement* firstNondefiningDeclaration = declarationStatement->get_firstNondefiningDeclaration();
1448 
1449 #if 0
1450  printf (" --- declarationStatement = %p \n",declarationStatement);
1451  printf (" --- definingDeclaration = %p \n",definingDeclaration);
1452  if (definingDeclaration != NULL && definingDeclaration->get_parent() != NULL)
1453  printf (" --- definingDeclaration ->get_parent() = %p = %s \n",definingDeclaration->get_parent(),definingDeclaration->get_parent()->class_name().c_str());
1454  printf (" --- firstNondefiningDeclaration = %p \n",firstNondefiningDeclaration);
1455  if (firstNondefiningDeclaration != NULL && firstNondefiningDeclaration->get_parent() != NULL)
1456  printf (" --- firstNondefiningDeclaration ->get_parent() = %p = %s \n",firstNondefiningDeclaration->get_parent(),firstNondefiningDeclaration->get_parent()->class_name().c_str());
1457 #endif
1458  if (definingDeclaration != NULL && declarationStatement != firstNondefiningDeclaration)
1459  {
1460 #if 0
1461  printf ("Found a nondefining declaration so use the non-defining declaration instead \n");
1462 #endif
1463  // DQ (10/19/2012): Use the defining declaration instead.
1464  // parent = firstNondefiningDeclaration;
1465  parent = definingDeclaration;
1466  }
1467  }
1468 
1469 #if 0
1470  printf ("reset: previouslySeenParent = %p = %s \n",previouslySeenParent,previouslySeenParent->class_name().c_str());
1471 #endif
1472 
1473  // DQ (10/19/2012): This branch is just to document the cycle that was previously detected, it is for
1474  // debugging only. Thus it ony make sense for it to be executed when "(foundCycle == true)". However,
1475  // this will have to be revisited later since it appears clear that it is a problem for the binary analysis
1476  // work when it is visited for this case. Since the cycle is detected, but there is no assertion on the
1477  // cycle, we don't exit when a cycle is identified (which is the point of the code below).
1478  // Note also that I have fixed the code (above and below) to only chase pointers through defining
1479  // declarations (where they exist), this is important since non-defining declarations can be almost
1480  // anywhere (and thus chasing them can make it appear that there are cycles where there are none
1481  // (I think); test2012_234.C demonstrates an example of this.
1482  // DQ (10/9/2012): Robb has suggested this change to fix the binary analysis work.
1483  // if (foundCycle == true)
1484  if (foundCycle == false)
1485  {
1486 
1487 
1488  while ( (parent != NULL) && (!dynamic_cast<const NodeType*>(parent)) )
1489  {
1490  ROSE_ASSERT(parent->get_parent() != parent);
1491 #if 0
1492  printf ("In getEnclosingNode() (2nd try): parent = %p = %s \n",parent,parent->class_name().c_str());
1493  if (parent->get_file_info() != NULL)
1494  parent->get_file_info()->display("In getEnclosingNode() (2nd try): debug");
1495 #endif
1496  SgDeclarationStatement* declarationStatement = isSgDeclarationStatement(parent);
1497  if (declarationStatement != NULL)
1498  {
1499 #if 0
1500  printf ("Found a SgDeclarationStatement \n");
1501 #endif
1502  SgDeclarationStatement* definingDeclaration = declarationStatement->get_definingDeclaration();
1503  SgDeclarationStatement* firstNondefiningDeclaration = declarationStatement->get_firstNondefiningDeclaration();
1504 #if 0
1505  printf (" --- declarationStatement = %p = %s \n",declarationStatement,(declarationStatement != NULL) ? declarationStatement->class_name().c_str() : "null");
1506 
1507  printf (" --- definingDeclaration = %p \n",definingDeclaration);
1508  if (definingDeclaration != NULL && definingDeclaration->get_parent() != NULL)
1509  printf (" --- definingDeclaration ->get_parent() = %p = %s \n",definingDeclaration->get_parent(),definingDeclaration->get_parent()->class_name().c_str());
1510 
1511  printf (" --- firstNondefiningDeclaration = %p \n",firstNondefiningDeclaration);
1512  if (firstNondefiningDeclaration != NULL && firstNondefiningDeclaration->get_parent() != NULL)
1513  printf (" --- firstNondefiningDeclaration ->get_parent() = %p = %s \n",firstNondefiningDeclaration->get_parent(),firstNondefiningDeclaration->get_parent()->class_name().c_str());
1514 #endif
1515  if (definingDeclaration != NULL && declarationStatement != firstNondefiningDeclaration)
1516  {
1517 #if 0
1518  printf ("Found a nondefining declaration so use the firstNondefining declaration instead \n");
1519 #endif
1520  // DQ (10/19/2012): Use the defining declaration instead.
1521  // parent = firstNondefiningDeclaration;
1522  parent = definingDeclaration;
1523  }
1524  }
1525 
1526  parent = parent->get_parent();
1527 
1528 #if 1
1529  // DQ (3/5/2012): Check for loops that will cause infinite loops.
1530  ROSE_ASSERT(parent != previouslySeenParent);
1531 #else
1532  printf ("WARNING::WARNING::WARNING commented out assertion for parent != previouslySeenParent \n");
1533  if (parent == previouslySeenParent)
1534  break;
1535 #endif
1536  }
1537  }
1538 
1539  return const_cast<NodeType*>(dynamic_cast<const NodeType*> (parent));
1540 #else
1541  // DQ (10/20/2012): Using Robb's newer version with my modification to use the definingDeclaration rather than firstNondefiningDeclaration (below).
1542 
1543  // Find the parent of specified type, but watch out for cycles in the ancestry (which would cause an infinite loop).
1544  // Cast away const because isSg* functions aren't defined for const node pointers; and our return is not const.
1545  SgNode *node = const_cast<SgNode*>(!astNode || includingSelf ? astNode : astNode->get_parent());
1546  std::set<const SgNode*> seen; // nodes we've seen, in order to detect cycles
1547  while (node) {
1548  if (NodeType *found = dynamic_cast<NodeType*>(node))
1549  return found;
1550 
1551  // FIXME: Cycle detection could be moved elsewhere so we don't need to do it on every call. [RPM 2012-10-09]
1552  ROSE_ASSERT(seen.insert(node).second);
1553 
1554  // Traverse to parent (declaration statements are a special case)
1555  if (SgDeclarationStatement *declarationStatement = isSgDeclarationStatement(node)) {
1556  SgDeclarationStatement *definingDeclaration = declarationStatement->get_definingDeclaration();
1557  SgDeclarationStatement *firstNondefiningDeclaration = declarationStatement->get_firstNondefiningDeclaration();
1558  if (definingDeclaration && firstNondefiningDeclaration && declarationStatement != firstNondefiningDeclaration) {
1559  // DQ (10/19/2012): Use the defining declaration instead.
1560  // node = firstNondefiningDeclaration;
1561  node = definingDeclaration;
1562  }
1563  } else {
1564  node = node->get_parent();
1565  }
1566  }
1567  return NULL;
1568 #endif
1569  }
1570 
1572  ROSE_DLL_API SgSourceFile* getEnclosingSourceFile(SgNode* n, const bool includingSelf=false);
1573 
1575  ROSE_DLL_API SgScopeStatement* getScope(const SgNode* astNode);
1576 
1578  ROSE_DLL_API SgScopeStatement* getEnclosingScope(SgNode* n, const bool includingSelf=false);
1579 
1581  ROSE_DLL_API SgGlobal* getGlobalScope( const SgNode* astNode);
1582 
1583 
1585  ROSE_DLL_API SgFunctionDefinition* getEnclosingProcedure(SgNode* n, const bool includingSelf=false);
1586 
1587  ROSE_DLL_API SgFunctionDefinition* getEnclosingFunctionDefinition(SgNode* astNode, const bool includingSelf=false);
1588 
1590  ROSE_DLL_API SgStatement* getEnclosingStatement(SgNode* n);
1591 
1594 
1597 
1599  ROSE_DLL_API SgScopeStatement* findEnclosingLoop(SgStatement* s, const std::string& fortranLabel = "", bool stopOnSwitches = false);
1600 
1602  ROSE_DLL_API SgFunctionDeclaration * getEnclosingFunctionDeclaration (SgNode * astNode, const bool includingSelf=false);
1603  //roseSupport/utility_functions.h
1605  ROSE_DLL_API SgFile* getEnclosingFileNode (SgNode* astNode );
1606 
1609 
1611  ROSE_DLL_API SgClassDefinition* getEnclosingClassDefinition(SgNode* astnode, const bool includingSelf=false);
1612 
1613 // TODO
1614 #if 0
1615  SgNode * getEnclosingSgNode(SgNode* source,VariantT, SgNode* endNode=NULL);
1616  std::vector<SgNode *> getAllEnclosingSgNode(SgNode* source,VariantT, SgNode* endNode=NULL);
1617  SgVariableDeclaration* findVariableDeclaratin( const string& varname)
1618 
1619  SgClassDeclaration* getEnclosingClassDeclaration( const SgNode* astNode);
1620 
1621  // e.g. for some expression, find its parent statement
1622  SgStatement* getEnclosingStatement(const SgNode* astNode);
1623 
1624  SgSwitchStatement* getEnclosingSwitch(SgStatement* s);
1625  SgModuleStatement* getEnclosingModuleStatement( const SgNode* astNode);
1626 
1627  // used to build a variable reference for compiler generated code in current scope
1628  SgSymbol * findReachingDefinition (SgScopeStatement* startScope, SgName &name);
1629 #endif
1630 
1631 
1632 //------------------------------------------------------------------------
1634 
1637  // Liao, 1/9/2008
1641  ROSE_DLL_API SgGlobal * getFirstGlobalScope(SgProject *project);
1642 
1646  ROSE_DLL_API SgStatement* getLastStatement(SgScopeStatement *scope);
1647 
1649  ROSE_DLL_API SgStatement* getFirstStatement(SgScopeStatement *scope,bool includingCompilerGenerated=false);
1652 
1654  ROSE_DLL_API SgStatement* getNextStatement(SgStatement * currentStmt);
1655 
1657  ROSE_DLL_API SgStatement* getPreviousStatement(SgStatement * currentStmt, bool climbOutScope = true);
1658 #if 0 //TODO
1659  // preorder traversal from current SgNode till find next SgNode of type V_SgXXX
1660  SgNode* getNextSgNode( const SgNode* currentNode, VariantT=V_SgNode);
1661 #endif
1662 
1663 
1664 //------------------------------------------------------------------------
1666 
1669  ROSE_DLL_API bool isEqualToIntConst(SgExpression* e, int value);
1671 
1673 
1676  ROSE_DLL_API bool isSameFunction(SgFunctionDeclaration* func1, SgFunctionDeclaration* func2);
1677 
1679  ROSE_DLL_API bool isLastStatement(SgStatement* stmt);
1680 
1682 
1683 //------------------------------------------------------------------------
1685 
1691 // DQ (2/24/2009): Simple function to delete an AST subtree (used in outlining).
1693 ROSE_DLL_API void deleteAST(SgNode* node);
1694 
1697 
1698 // DQ (2/25/2009): Added new function to support outliner.
1700 ROSE_DLL_API void moveStatementsBetweenBlocks ( SgBasicBlock* sourceBlock, SgBasicBlock* targetBlock );
1701 
1703 ROSE_DLL_API void moveVariableDeclaration(SgVariableDeclaration* decl, SgScopeStatement* target_scope);
1705 ROSE_DLL_API void appendStatement(SgStatement *stmt, SgScopeStatement* scope=NULL);
1706 
1708 ROSE_DLL_API void appendStatement(SgStatement *stmt, SgForInitStatement* for_init_stmt);
1709 
1711 ROSE_DLL_API void appendStatementList(const std::vector<SgStatement*>& stmt, SgScopeStatement* scope=NULL);
1712 
1713 // DQ (2/6/2009): Added function to support outlining into separate file.
1715 ROSE_DLL_API void appendStatementWithDependentDeclaration( SgDeclarationStatement* decl, SgGlobal* scope, SgStatement* original_statement, bool excludeHeaderFiles );
1716 
1719 ROSE_DLL_API void prependStatement(SgStatement *stmt, SgScopeStatement* scope=NULL);
1720 
1722 ROSE_DLL_API void prependStatement(SgStatement *stmt, SgForInitStatement* for_init_stmt);
1723 
1726 ROSE_DLL_API void prependStatementList(const std::vector<SgStatement*>& stmt, SgScopeStatement* scope=NULL);
1727 
1731 ROSE_DLL_API bool hasSimpleChildrenList (SgScopeStatement* scope);
1732 
1734 ROSE_DLL_API void insertStatement(SgStatement *targetStmt, SgStatement* newStmt, bool insertBefore= true, bool autoMovePreprocessingInfo = true);
1735 
1737 //target's scope
1738 ROSE_DLL_API void insertStatementList(SgStatement *targetStmt, const std::vector<SgStatement*>& newStmts, bool insertBefore= true);
1739 
1741 ROSE_DLL_API void insertStatementBefore(SgStatement *targetStmt, SgStatement* newStmt, bool autoMovePreprocessingInfo = true);
1742 
1744 ROSE_DLL_API void insertStatementListBefore(SgStatement *targetStmt, const std::vector<SgStatement*>& newStmts);
1745 
1747 ROSE_DLL_API void insertStatementAfter(SgStatement *targetStmt, SgStatement* newStmt, bool autoMovePreprocessingInfo = true);
1748 
1750 ROSE_DLL_API void insertStatementListAfter(SgStatement *targetStmt, const std::vector<SgStatement*>& newStmt);
1751 
1753 ROSE_DLL_API void insertStatementAfterLastDeclaration(SgStatement* stmt, SgScopeStatement* scope);
1754 
1756 ROSE_DLL_API void insertStatementAfterLastDeclaration(std::vector<SgStatement*> stmt_list, SgScopeStatement* scope);
1757 
1759 // then the statement is inserted at the end of the scope.
1760 ROSE_DLL_API void insertStatementBeforeFirstNonDeclaration(SgStatement *newStmt, SgScopeStatement *scope,
1761  bool movePreprocessingInfo=true);
1762 
1764 //then the new statements are inserted at the end of the scope.
1765 ROSE_DLL_API void insertStatementListBeforeFirstNonDeclaration(const std::vector<SgStatement*> &newStmts,
1766  SgScopeStatement *scope);
1767 
1769 ROSE_DLL_API void removeStatement(SgStatement* stmt, bool autoRelocatePreprocessingInfo = true);
1770 
1772 ROSE_DLL_API void deepDelete(SgNode* root);
1773 
1775 ROSE_DLL_API void replaceStatement(SgStatement* oldStmt, SgStatement* newStmt, bool movePreprocessinInfo = false);
1776 
1778 ROSE_DLL_API SgNode* replaceWithPattern (SgNode * anchor, SgNode* new_pattern);
1779 
1781 // Essentially replace variable a with b.
1782 ROSE_DLL_API void replaceVariableReferences(SgVariableSymbol* old_sym, SgVariableSymbol* new_sym, SgScopeStatement * scope );
1783 
1794 std::pair<SgVariableDeclaration*, SgExpression* > createTempVariableForExpression(SgExpression* expression,
1795  SgScopeStatement* scope, bool initializeInDeclaration, SgAssignOp** reEvaluate = NULL);
1796 
1797 /* This function creates a temporary variable for a given expression in the given scope
1798  This is different from SageInterface::createTempVariableForExpression in that it does not
1799  try to be smart to create pointers to reference types and so on. The tempt is initialized to expression.
1800  The caller is responsible for setting the parent of SgVariableDeclaration since buildVariableDeclaration
1801  may not set_parent() when the scope stack is empty. See programTransformation/extractFunctionArgumentsNormalization/ExtractFunctionArguments.C for sample usage.
1802  @param expression Expression which will be replaced by a variable
1803  @param scope scope in which the temporary variable will be generated
1804 */
1805 
1806 std::pair<SgVariableDeclaration*, SgExpression*> createTempVariableAndReferenceForExpression
1807  (SgExpression* expression, SgScopeStatement* scope);
1808 
1810 
1817 
1819 ROSE_DLL_API void appendExpression(SgExprListExp *, SgExpression*);
1820 
1822 ROSE_DLL_API void appendExpressionList(SgExprListExp *, const std::vector<SgExpression*>&);
1823 
1825 template <class actualFunction>
1826 void setParameterList(actualFunction *func,SgFunctionParameterList *paralist) {
1827 
1828  // TODO consider the difference between C++ and Fortran
1829  // fixup the scope of arguments,no symbols for nondefining function declaration's arguments
1830 
1831  // DQ (11/25/2011): templated function so that we can handle both
1832  // SgFunctionDeclaration and SgTemplateFunctionDeclaration (and their associated member
1833  // function derived classes).
1834 
1835  ROSE_ASSERT(func != NULL);
1836  ROSE_ASSERT(paralist != NULL);
1837 
1838 #if 0
1839  // At this point we don't have cerr and endl defined, so comment this code out.
1840  // Warn to users if a paralist is being shared
1841  if (paralist->get_parent() !=NULL)
1842  {
1843  cerr << "Waring! Setting a used SgFunctionParameterList to function: "
1844  << (func->get_name()).getString()<<endl
1845  << " Sharing parameter lists can corrupt symbol tables!"<<endl
1846  << " Please use deepCopy() to get an exclusive parameter list for each function declaration!"<<endl;
1847  // ROSE_ASSERT(false);
1848  }
1849 #endif
1850 
1851  // Liao,2/5/2008 constructor of SgFunctionDeclaration will automatically generate SgFunctionParameterList, so be cautious when set new paralist!!
1852  if (func->get_parameterList() != NULL)
1853  {
1854  if (func->get_parameterList() != paralist)
1855  {
1856  delete func->get_parameterList();
1857  }
1858  }
1859 
1860  func->set_parameterList(paralist);
1861  paralist->set_parent(func);
1862 
1863  // DQ (5/15/2012): Need to set the declptr in each SgInitializedName IR node.
1864  // This is needed to support the AST Copy mechanism (at least). The files: test2005_150.C,
1865  // test2012_81.C and testcode2012_82.C demonstrate this problem.
1866  SgInitializedNamePtrList & args = paralist->get_args();
1867  for (SgInitializedNamePtrList::iterator i = args.begin(); i != args.end(); i++)
1868  {
1869  (*i)->set_declptr(func);
1870  }
1871  }
1872 
1874 ROSE_DLL_API void setPragma(SgPragmaDeclaration* decl, SgPragma *pragma);
1875 
1877 ROSE_DLL_API void replaceExpression(SgExpression* oldExp, SgExpression* newExp, bool keepOldExp=false);
1878 
1880 ROSE_DLL_API void replaceExpressionWithStatement(SgExpression* from,
1884 ROSE_DLL_API void replaceSubexpressionWithStatement(SgExpression* from,
1886 
1888 ROSE_DLL_API void setOperand(SgExpression* target, SgExpression* operand);
1889 
1891 ROSE_DLL_API void setLhsOperand(SgExpression* target, SgExpression* lhs);
1892 
1894 ROSE_DLL_API void setRhsOperand(SgExpression* target, SgExpression* rhs);
1895 
1897 ROSE_DLL_API void removeAllOriginalExpressionTrees(SgNode* top);
1898 
1899 // DQ (1/25/2010): Added support for directories
1901 ROSE_DLL_API void moveToSubdirectory ( std::string directoryName, SgFile* file );
1902 
1904 ROSE_DLL_API SgStatement* findSurroundingStatementFromSameFile(SgStatement* targetStmt, bool & surroundingStatementPreceedsTargetStatement);
1905 
1907 ROSE_DLL_API void moveCommentsToNewStatement(SgStatement* sourceStatement, const std::vector<int> & indexList, SgStatement* targetStatement, bool surroundingStatementPreceedsTargetStatement);
1908 
1909 // DQ (7/19/2015): This is required to support general unparsing of template instantations for the GNU g++
1910 // compiler which does not permit name qualification to be used to support the expression of the namespace
1911 // where a template instantiatoon would be places. Such name qualification would also sometimes require
1912 // global qualification which is also not allowed by the GNU g++ compiler. These issues appear to be
1913 // specific to the GNU compiler versions, at least versions 4.4 through 4.8.
1915 ROSE_DLL_API void moveDeclarationToAssociatedNamespace ( SgDeclarationStatement* declarationStatement );
1916 
1917 ROSE_DLL_API bool isTemplateInstantiationNode(SgNode* node);
1918 
1920 
1921 // DQ (12/1/2015): Adding support for fixup internal data struuctures that have references to statements (e.g. macro expansions).
1922 ROSE_DLL_API void resetInternalMapsForTargetStatement(SgStatement* sourceStatement);
1923 
1925 //------------------------------------------------------------------------
1927 
1934 
1940 ROSE_DLL_API int fixVariableReferences(SgNode* root);
1941 
1943 
1947 ROSE_DLL_API void fixVariableDeclaration(SgVariableDeclaration* varDecl, SgScopeStatement* scope);
1948 
1950 ROSE_DLL_API void fixStructDeclaration(SgClassDeclaration* structDecl, SgScopeStatement* scope);
1952 ROSE_DLL_API void fixClassDeclaration(SgClassDeclaration* classDecl, SgScopeStatement* scope);
1953 
1955 ROSE_DLL_API void fixNamespaceDeclaration(SgNamespaceDeclarationStatement* structDecl, SgScopeStatement* scope);
1956 
1957 
1959 ROSE_DLL_API void fixLabelStatement(SgLabelStatement* label_stmt, SgScopeStatement* scope);
1960 
1962 ROSE_DLL_API void setFortranNumericLabel(SgStatement* stmt, int label_value);
1963 
1965 ROSE_DLL_API int suggestNextNumericLabel(SgFunctionDefinition* func_def);
1966 
1968 ROSE_DLL_API void fixFunctionDeclaration(SgFunctionDeclaration* stmt, SgScopeStatement* scope);
1969 
1971 ROSE_DLL_API void fixTemplateDeclaration(SgTemplateDeclaration* stmt, SgScopeStatement* scope);
1972 
1974 ROSE_DLL_API void fixStatement(SgStatement* stmt, SgScopeStatement* scope);
1975 
1976 // DQ (6/11/2015): This reports the statements that are marked as transformed (used to debug the token-based unparsing).
1978 ROSE_DLL_API std::set<SgStatement*> collectTransformedStatements( SgNode* node );
1979 
1981 ROSE_DLL_API std::set<SgStatement*> collectModifiedStatements( SgNode* node );
1982 
1984 ROSE_DLL_API std::set<SgLocatedNode*> collectModifiedLocatedNodes( SgNode* node );
1985 
1987 
1989 
1995 
1996 //------------------------------------------------------------------------
1998 
2002 ROSE_DLL_API bool
2004 collectReadWriteRefs(SgStatement* stmt, std::vector<SgNode*>& readRefs, std::vector<SgNode*>& writeRefs, bool useCachedDefUse=false);
2005 
2007 ROSE_DLL_API bool collectReadWriteVariables(SgStatement* stmt, std::set<SgInitializedName*>& readVars, std::set<SgInitializedName*>& writeVars, bool coarseGrain=true);
2008 
2010 ROSE_DLL_API void collectReadOnlyVariables(SgStatement* stmt, std::set<SgInitializedName*>& readOnlyVars, bool coarseGrain=true);
2011 
2013 ROSE_DLL_API void collectReadOnlySymbols(SgStatement* stmt, std::set<SgVariableSymbol*>& readOnlySymbols, bool coarseGrain=true);
2014 
2016 ROSE_DLL_API bool isUseByAddressVariableRef(SgVarRefExp* ref);
2017 
2019 ROSE_DLL_API void collectUseByAddressVariableRefs (const SgStatement* s, std::set<SgVarRefExp* >& varSetB);
2020 
2021 #ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
2022 ROSE_DLL_API LivenessAnalysis * call_liveness_analysis(SgProject* project, bool debug=false);
2024 
2026 ROSE_DLL_API void getLiveVariables(LivenessAnalysis * liv, SgForStatement* loop, std::set<SgInitializedName*>& liveIns, std::set<SgInitializedName*> & liveOuts);
2027 #endif
2028 
2030 ROSE_DLL_API void ReductionRecognition(SgForStatement* loop, std::set< std::pair <SgInitializedName*, OmpSupport::omp_construct_enum> > & results);
2031 
2033 
2034 ROSE_DLL_API void constantFolding(SgNode* r);
2035 
2037 
2039 ROSE_DLL_API int instrumentEndOfFunction(SgFunctionDeclaration * func, SgStatement* s);
2040 
2042 ROSE_DLL_API void removeJumpsToNextStatement(SgNode*);
2043 
2045 ROSE_DLL_API void removeUnusedLabels(SgNode* top);
2046 
2048 ROSE_DLL_API void removeConsecutiveLabels(SgNode* top);
2049 
2051 
2057 ROSE_DLL_API bool mergeDeclarationAndAssignment (SgVariableDeclaration* decl, SgExprStatement* assign_stmt, bool removeAssignStmt = true);
2058 
2059 
2061 ROSE_DLL_API bool mergeAssignmentWithDeclaration (SgExprStatement* assign_stmt, SgVariableDeclaration* decl, bool removeAssignStmt = true);
2062 
2064 
2067 ROSE_DLL_API bool mergeDeclarationWithAssignment (SgVariableDeclaration* decl, SgExprStatement* assign_stmt);
2068 
2070 
2075 
2077 ROSE_DLL_API int splitVariableDeclaration (SgScopeStatement* scope, bool topLevelOnly = true);
2078 
2080 
2087  ROSE_DLL_API SgAssignInitializer* splitExpression(SgExpression* from, std::string newName = "");
2088 
2090 ROSE_DLL_API void splitExpressionIntoBasicBlock(SgExpression* expr);
2091 
2093 ROSE_DLL_API void removeLabeledGotos(SgNode* top);
2094 
2096 ROSE_DLL_API void changeBreakStatementsToGotos(SgStatement* loopOrSwitch);
2097 
2100 
2103 
2106 
2109 
2112 
2115 
2118 
2121 
2123 ROSE_DLL_API SgBasicBlock* ensureBasicBlockAsFalseBodyOfIf(SgIfStmt* ifs, bool createEmptyBody = true);
2124 
2127 
2130 
2131 // DQ (1/18/2015): This is added to support better quality token-based unparsing.
2133 ROSE_DLL_API void cleanupNontransformedBasicBlockNode();
2134 
2135 // DQ (1/18/2015): This is added to support better quality token-based unparsing.
2137 ROSE_DLL_API void recordNormalizations(SgStatement* s);
2138 
2141 bool isBodyStatement (SgStatement* s);
2142 
2144 void changeAllBodiesToBlocks(SgNode* top, bool createEmptyBody = true);
2145 
2146 // The same as changeAllBodiesToBlocks(SgNode* top). Phased out.
2147 //void changeAllLoopBodiesToBlocks(SgNode* top);
2148 
2151 
2152 #if 0
2153 
2156 SgLocatedNode* ensureBasicBlockAsParent(SgStatement* s);
2157 #endif
2158 
2161 unsigned long long getIntegerConstantValue(SgValueExp* expr);
2162 
2164 std::vector<SgDeclarationStatement*> getDependentDeclarations (SgStatement* stmt );
2165 
2166 
2169 
2171 SgCommaOpExp *insertAfterUsingCommaOp (SgExpression* new_exp, SgExpression* anchor_exp, SgStatement** temp_decl = NULL, SgVarRefExp** temp_ref = NULL);
2172 
2173 
2203 std::pair<SgStatement*, SgInitializedName*>
2204 wrapFunction(SgFunctionDeclaration& definingDeclaration, SgName newName);
2205 
2211 template <class NameGen>
2212 std::pair<SgStatement*, SgInitializedName*>
2213 wrapFunction(SgFunctionDeclaration& definingDeclaration, NameGen nameGen)
2214 {
2215  return wrapFunction(definingDeclaration, nameGen(definingDeclaration.get_name()));
2216 }
2217 
2221 
2222 
2224 
2225 // DQ (6/7/2012): Unclear where this function should go...
2226  bool hasTemplateSyntax( const SgName & name );
2227 
2228 #if 0
2229 
2230 //------------------------AST dump, stringify-----------------------------
2231 //------------------------------------------------------------------------
2232  std::string buildOperatorString ( SgNode* astNode ); //transformationSupport.h
2233 
2234  // do we need these?
2235  std::string dump_node(const SgNode* astNode);
2236  std::string dump_tree(const SgNode* astNode);
2237 
2238  // or a friendly version of unparseToString(), as a memeber function
2239  std::string SgNode::toString(bool asSubTree=true); // dump node or subtree
2240 
2241 //----------------------------AST comparison------------------------------
2242 //------------------------------------------------------------------------
2243 // How to get generic functions for comparison?
2244  bool isNodeEqual(SgNode* node1, SgNode* node2); //?
2245  bool isTreeEqual(SgNode* tree1, SgNode* tree2);
2246 
2248  bool expressionTreeEqual(SgExpression*, SgExpression*);
2250  bool expressionTreeEqualStar(const SgExpressionPtrList&,
2251  const SgExpressionPtrList&);
2252 
2253 //----------------------AST verfication/repair----------------------------
2254 //------------------------------------------------------------------------
2255 // sanity check of AST subtree, any suggestions?
2256 // TODO
2257  verifySgNode(SgNode* node, bool subTree=true);
2258  //src/midend/astDiagnostics/AstConsistencyTests.h
2259  // AstTests::runAllTests(SgProject * )
2260 
2261  //src/midend/astUtil/astInterface/AstInterface.h.C
2262  //FixSgProject(SgProject &project)
2263  //FixSgTree(SgNode* r)
2264 
2265  //src/frontend/SageIII/astPostProcessing
2266  //AstPostProcessing(SgNode * node)
2267 
2268 //--------------------------AST modification------------------------------
2269 //------------------------------------------------------------------------
2270 // any operations changing AST tree, including
2271 // insert, copy, delete(remove), replace
2272 
2273  // insert before or after some point, argument list is consistent with LowLevelRewrite
2274  void insertAst(SgNode* targetPosition, SgNode* newNode, bool insertBefore=true);
2275 
2276  // previous examples
2277  //void myStatementInsert(SgStatement* target,...)
2278  // void AstInterfaceBase::InsertStmt(AstNodePtr const & orig, AstNodePtr const &n, bool insertbefore, bool extractfromBasicBlock)
2279 
2280  // copy
2281  // copy children of one basic block to another basic block
2282  //void appendStatementCopy (const SgBasicBlock* a, SgBasicBlock* b);
2283  void copyStatements (const SgBasicBlock* src, SgBasicBlock* dst);
2284 
2285  // delete (remove) a node or a whole subtree
2286  void removeSgNode(SgNode* targetNode); // need this?
2287  void removeSgNodeTree(SgNode* subtree); // need this?
2288 
2289  void removeStatement( SgStatement* targetStmt);
2290 
2291  //Move = delete + insert
2292  void moveAst (SgNode* src, SgNode* target); // need this?
2293  // similar to
2294  void moveStatements (SgBasicBlock* src, SgBasicBlock* target);
2295 
2296  // replace= delete old + insert new (via building or copying)
2297 
2298 // DQ (1/25/2010): This does not appear to exist as a definition anywhere in ROSE.
2299 // void replaceAst(SgNode* oldNode, SgNode* newNode);
2300 
2301  //void replaceChild(SgNode* parent, SgNode* from, SgNode* to);
2302  //bool AstInterface::ReplaceAst( const AstNodePtr& orig, const AstNodePtr& n)
2303 
2304 //--------------------------AST transformations---------------------------
2305 //------------------------------------------------------------------------
2306 // Advanced AST modifications through basic AST modifications
2307 // Might not be included in AST utitlity list, but listed here for the record.
2308 
2309  // extract statements/content from a scope
2310  void flattenBlocks(SgNode* n);
2311 
2312  //src/midend/astInlining/inlinerSupport.h
2313  void renameVariables(SgNode* n);
2314  void renameLabels(SgNode* n, SgFunctionDefinition* enclosingFunctionDefinition);
2315 
2316  void simpleCopyAndConstantPropagation(SgNode* top);
2317  void changeAllMembersToPublic(SgNode* n);
2318 
2319  void removeVariableDeclaration(SgInitializedName* initname);
2320 
2322  SgAssignOp* convertInitializerIntoAssignment(SgAssignInitializer* init);
2323 
2328  void pushTestIntoBody(LoopStatement* loopStmt);
2329 
2330  //programTransformation/finiteDifferencing/finiteDifferencing.h
2332  void moveForDeclaredVariables(SgNode* root);
2333 
2334 //------------------------ Is/Has functions ------------------------------
2335 //------------------------------------------------------------------------
2336 // misc. boolean functions
2337 // some of them could moved to SgXXX class as a member function
2338 
2339  bool isOverloaded (SgFunctionDeclaration * functionDeclaration);
2340 
2341  bool isSwitchCond (const SgStatement* s);
2342  bool isIfCond (const SgStatement* s);
2343  bool isWhileCond (const SgStatement* s);
2344  bool isStdNamespace (const SgScopeStatement* scope);
2345  bool isTemplateInst (const SgDeclarationStatement* decl);
2346 
2347 
2348  bool isCtor (const SgFunctionDeclaration* func);
2349  bool isDtor (const SgFunctionDeclaration* func);
2350 
2351  // src/midend/astInlining/typeTraits.h
2352  bool hasTrivialDestructor(SgType* t);
2353  ROSE_DLL_API bool isNonconstReference(SgType* t);
2354  ROSE_DLL_API bool isReferenceType(SgType* t);
2355 
2356  // generic ones, or move to the SgXXX class as a member function
2357 
2358  bool isConst(SgNode* node); // const type, variable, function, etc.
2359  // .... and more
2360 
2361  bool isConstType (const SgType* type);
2362  bool isConstFunction (const SgFunctionDeclaration* decl);
2363 
2364 
2365  bool isMemberVariable(const SgInitializedName & var);
2366  //bool isMemberVariable(const SgNode& in);
2367 
2368  bool isPrototypeInScope (SgScopeStatement * scope,
2369  SgFunctionDeclaration * functionDeclaration,
2370  SgDeclarationStatement * startingAtDeclaration);
2371 
2372  bool MayRedefined(SgExpression* expr, SgNode* root);
2373  // bool isPotentiallyModified(SgExpression* expr, SgNode* root); // inlinderSupport.h
2374  bool hasAddressTaken(SgExpression* expr, SgNode* root);
2375 
2376  //src/midend/astInlining/inlinerSupport.C
2377  // can also classified as topdown search
2378  bool containsVariableReference(SgNode* root, SgInitializedName* var);
2379 
2380  bool isDeclarationOf(SgVariableDeclaration* decl, SgInitializedName* var);
2381  bool isPotentiallyModifiedDuringLifeOf(SgBasicBlock* sc,
2382  SgInitializedName* toCheck,
2383  SgInitializedName* lifetime)
2384  //src/midend/programTransformation/partialRedundancyElimination/pre.h
2385  bool anyOfListPotentiallyModifiedIn(const std::vector<SgVariableSymbol*>& syms, SgNode* n);
2386 
2387 //------------------------ loop handling ---------------------------------
2388 //------------------------------------------------------------------------
2389  //get and set loop control expressions
2390  // 0: init expr, 1: condition expr, 2: stride expr
2391 
2392  SgExpression* getForLoopTripleValues(int valuetype,SgForStatement* forstmt );
2393  int setForLoopTripleValues(int valuetype,SgForStatement* forstmt, SgExpression* exp);
2394 
2395  bool isLoopIndexVarRef(SgForStatement* forstmt, SgVarRefExp *varref);
2396  SgInitializedName * getLoopIndexVar(SgForStatement* forstmt);
2397 
2398 //------------------------expressions-------------------------------------
2399 //------------------------------------------------------------------------
2400  //src/midend/programTransformation/partialRedundancyElimination/pre.h
2401  int countComputationsOfExpressionIn(SgExpression* expr, SgNode* root);
2402 
2403  //src/midend/astInlining/replaceExpressionWithStatement.h
2404  void replaceAssignmentStmtWithStatement(SgExprStatement* from, StatementGenerator* to);
2405 
2407  StatementGenerator* to);
2408  SgExpression* getRootOfExpression(SgExpression* n);
2409 
2410 //--------------------------preprocessing info. -------------------------
2411 //------------------------------------------------------------------------
2413  void cutPreprocInfo (SgBasicBlock* b,
2415  AttachedPreprocessingInfoType& save_buf);
2417  void pastePreprocInfoFront (AttachedPreprocessingInfoType& save_buf,
2418  SgStatement* s);
2420  void pastePreprocInfoBack (AttachedPreprocessingInfoType& save_buf,
2421  SgStatement* s);
2422 
2428  // a generic one for all
2430  void moveBeforePreprocInfo (SgStatement* src, SgStatement* dest);
2431  void moveInsidePreprocInfo (SgBasicBlock* src, SgBasicBlock* dest);
2432  void moveAfterPreprocInfo (SgStatement* src, SgStatement* dest);
2433 
2434 //--------------------------------operator--------------------------------
2435 //------------------------------------------------------------------------
2436  from transformationSupport.h, not sure if they should be included here
2437  /* return enum code for SAGE operators */
2438  operatorCodeType classifyOverloadedOperator(); // transformationSupport.h
2439 
2445  std::string stringifyOperator (std::string name);
2446 
2447 //--------------------------------macro ----------------------------------
2448 //------------------------------------------------------------------------
2449  std::string buildMacro ( std::string s ); //transformationSupport.h
2450 
2451 //--------------------------------access functions---------------------------
2452 //----------------------------------get/set sth.-----------------------------
2453 // several categories:
2454 * get/set a direct child/grandchild node or fields
2455 * get/set a property flag value
2456 * get a descendent child node using preorder searching
2457 * get an ancestor node using bottomup/reverse searching
2458 
2459  // SgName or string?
2460  std::string getFunctionName (SgFunctionCallExp* functionCallExp);
2461  std::string getFunctionTypeName ( SgFunctionCallExp* functionCallExpression );
2462 
2463  // do we need them anymore? or existing member functions are enought?
2464  // a generic one:
2465  std::string get_name (const SgNode* node);
2466  std::string get_name (const SgDeclarationStatement * declaration);
2467 
2468  // get/set some property: should moved to SgXXX as an inherent memeber function?
2469  // access modifier
2470  void setExtern (SgFunctionDeclartion*)
2471  void clearExtern()
2472 
2473  // similarly for other declarations and other properties
2475  void setPublic()
2476  void setPrivate()
2477 
2478 #endif
2479 
2480 // DQ (1/23/2013): Added support for generated a set of source sequence entries.
2481  std::set<unsigned int> collectSourceSequenceNumbers( SgNode* astNode );
2482 
2483 //--------------------------------Type Traits (C++)---------------------------
2484  bool HasNoThrowAssign(const SgType * const inputType);
2485  bool HasNoThrowCopy(const SgType * const inputType);
2486  bool HasNoThrowConstructor(const SgType * const inputType);
2487  bool HasTrivialAssign(const SgType * const inputType);
2488  bool HasTrivialCopy(const SgType * const inputType);
2489  bool HasTrivialConstructor(const SgType * const inputType);
2490  bool HasTrivialDestructor(const SgType * const inputType);
2491  bool HasVirtualDestructor(const SgType * const inputType);
2492  bool IsBaseOf(const SgType * const inputBaseType, const SgType * const inputDerivedType);
2493  bool IsAbstract(const SgType * const inputType);
2494  bool IsClass(const SgType * const inputType);
2495  bool IsEmpty(const SgType * const inputType);
2496  bool IsEnum(const SgType * const inputType);
2497  bool IsPod(const SgType * const inputType);
2498  bool IsPolymorphic(const SgType * const inputType);
2499  bool IsStandardLayout(const SgType * const inputType);
2500  bool IsLiteralType(const SgType * const inputType);
2501  bool IsTrivial(const SgType * const inputType);
2502  bool IsUnion(const SgType * const inputType);
2503  SgType * UnderlyingType(SgType *type);
2504 
2505 // DQ (3/2/2014): Added a new interface function (used in the snippet insertion support).
2506 // void supportForInitializedNameLists ( SgScopeStatement* scope, SgInitializedNamePtrList & variableList );
2507 
2508 // DQ (3/4/2014): Added support for testing two trees for equivalents using the AST iterators.
2509  bool isStructurallyEquivalentAST( SgNode* tree1, SgNode* tree2 );
2510 
2511 // JP (10/14/24): Moved code to evaluate a const integer expression (like in array size definitions) to SageInterface
2514  size_t value_;
2515  bool hasValue_;
2516  };
2519 
2520 // JP (9/17/14): Added function to test whether two SgType* are equivalent or not
2521  bool checkTypesAreEqual(SgType *typeA, SgType *typeB);
2522 
2523 //--------------------------------Java interface functions ---------------------
2524 #ifdef ROSE_BUILD_JAVA_LANGUAGE_SUPPORT
2525  ROSE_DLL_API std::string getTempDirectory(SgProject *project);
2526  ROSE_DLL_API void destroyTempDirectory(std::string);
2527  ROSE_DLL_API SgFile *processFile(SgProject *, std::string, bool unparse = false);
2528  ROSE_DLL_API std::string preprocessPackage(SgProject *, std::string);
2529  ROSE_DLL_API std::string preprocessImport(SgProject *, std::string);
2530  ROSE_DLL_API SgFile* preprocessCompilationUnit(SgProject *, std::string, std::string, bool unparse = true);
2531  ROSE_DLL_API SgClassDefinition *findJavaPackage(SgScopeStatement *, std::string);
2532  ROSE_DLL_API SgClassDefinition *findOrInsertJavaPackage(SgProject *, std::string, bool create_directory = false);
2533  ROSE_DLL_API SgClassDeclaration *findOrImportJavaClass(SgProject *, SgClassDefinition *package_definition, std::string);
2534  ROSE_DLL_API SgClassDeclaration *findOrImportJavaClass(SgProject *, std::string, std::string);
2535  ROSE_DLL_API SgClassDeclaration *findOrImportJavaClass(SgProject *, SgClassType *);
2536  ROSE_DLL_API SgMemberFunctionDeclaration *findJavaMain(SgClassDefinition *);
2537  ROSE_DLL_API SgMemberFunctionDeclaration *findJavaMain(SgClassType *);
2538 #endif // ROSE_BUILD_JAVA_LANGUAGE_SUPPORT
2539 
2540 
2541 
2542 // DQ (8/31/2016): Making this a template function so that we can have it work with user defined filters.
2544 
2550 template < class T >
2552  {
2553  // DQ (9/1/2016): This function is called in the Call graph generation to avoid filtering out EDG normalized
2554  // function template instnatiations (which come from normalized template functions and member functions).
2555  // Note that because of the EDG normailzation the membr function is moved outside of the class, and
2556  // thus marked as compiler generated. However the template instantiations are always marked as compiler
2557  // generated (if not specializations) and so we want to include a template instantiation that is marked
2558  // as compiler generated, but is from a template declaration that satisfyied a specific user defined filter.
2559  // The complexity of this detection is isolated here, but knowing that it must be called is more complex.
2560  // This function is call in the CG.C file of tests/nonsmoke/functional/roseTests/programAnalysisTests/testCallGraphAnalysis.
2561 
2562  bool retval = false;
2563 
2564 #define DEBUG_TEMPLATE_NORMALIZATION_DETECTION 0
2565 
2566 #if DEBUG_TEMPLATE_NORMALIZATION_DETECTION
2567  printf ("In isNormalizedTemplateInstantiation(): function = %p = %s = %s \n",function,function->class_name().c_str(),function->get_name().str());
2568 #endif
2569 
2570  // Test for this to be a template instantation (in which case it was marked as
2571  // compiler generated but we may want to allow it to be used in the call graph,
2572  // if it's template was a part was defined in the current directory).
2573  SgTemplateInstantiationFunctionDecl* templateInstantiationFunction = isSgTemplateInstantiationFunctionDecl(function);
2574  SgTemplateInstantiationMemberFunctionDecl* templateInstantiationMemberFunction = isSgTemplateInstantiationMemberFunctionDecl(function);
2575 
2576  if (templateInstantiationFunction != NULL)
2577  {
2578  // When the defining function has been normalized by EDG, only the non-defining declaration will have a source position.
2579  templateInstantiationFunction = isSgTemplateInstantiationFunctionDecl(templateInstantiationFunction->get_firstNondefiningDeclaration());
2580  SgTemplateFunctionDeclaration* templateFunctionDeclaration = templateInstantiationFunction->get_templateDeclaration();
2581  if (templateFunctionDeclaration != NULL)
2582  {
2583  retval = filter->operator()(templateFunctionDeclaration);
2584  }
2585  else
2586  {
2587  // Assume false.
2588  }
2589 
2590 #if DEBUG_TEMPLATE_NORMALIZATION_DETECTION
2591  printf (" --- case of templateInstantiationFunction: retval = %s \n",retval ? "true" : "false");
2592 #endif
2593  }
2594  else
2595  {
2596  if (templateInstantiationMemberFunction != NULL)
2597  {
2598  // When the defining function has been normalized by EDG, only the non-defining declaration will have a source position.
2599  templateInstantiationMemberFunction = isSgTemplateInstantiationMemberFunctionDecl(templateInstantiationMemberFunction->get_firstNondefiningDeclaration());
2600  SgTemplateMemberFunctionDeclaration* templateMemberFunctionDeclaration = templateInstantiationMemberFunction->get_templateDeclaration();
2601  if (templateMemberFunctionDeclaration != NULL)
2602  {
2603  retval = filter->operator()(templateMemberFunctionDeclaration);
2604  }
2605  else
2606  {
2607  // Assume false.
2608  }
2609 
2610 #if DEBUG_TEMPLATE_NORMALIZATION_DETECTION
2611  printf (" --- case of templateInstantiationMemberFunction: retval = %s \n",retval ? "true" : "false");
2612 #endif
2613  }
2614  }
2615 
2616  return retval;
2617  }
2618 
2619 
2620 
2621 }// end of namespace
2622 
2623 #endif
std::string extractPragmaKeyword(const SgPragmaDeclaration *)
Extract a SgPragmaDeclaration's leading keyword . For example "#pragma omp parallel" has a keyword of...
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 SgStatement * findSurroundingStatementFromSameFile(SgStatement *targetStmt, bool &surroundingStatementPreceedsTargetStatement)
Supporting function to comment relocation in insertStatement() and removeStatement().
ROSE_DLL_API SgFunctionDeclaration * findFirstDefiningFunctionDecl(SgScopeStatement *scope)
Find the first defining function declaration statement in a scope.
This class represents the notion of an initializer for a variable declaration or expression in a func...
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.
ROSE_DLL_API bool is_mixed_Fortran_and_C_and_Cxx_language()
ROSE_DLL_API size_t getUpcSharedBlockSize(SgModifierType *mod_type)
Get the block size of a UPC shared modifier type.
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...
This class represents the concept of a scope in C++ (e.g. global scope, fuction scope, etc.).
ROSE_DLL_API void insertStatementListAfter(SgStatement *targetStmt, const std::vector< SgStatement * > &newStmt)
Insert a list of statements after a target statement.
This class represents the concept of an instantiation of member function template or a member functio...
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, with the step statement after it; then change all continue statements in the old loop body into jumps to the label.
A persistent attribute to represent a unique name for an expression.
ROSE_DLL_API SgFile * getEnclosingFileNode(SgNode *astNode)
get the SgFile node from current node
This class represents the concept of a class declaration statement. It includes the concept of an ins...
bool declarationPreceedsDefinition(SgDeclarationStatement *nonDefiningDeclaration, SgDeclarationStatement *definingDeclaration)
Check if a defining declaration comes before of after the non-defining declaration.
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, with the step statement after it; then change all continue statements in the old loop body into jumps to the label.
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...
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...
ROSE_DLL_API SgStatement * getEnclosingStatement(SgNode *n)
Find the closest enclosing statement, including the given node.
std::string generateUniqueNameForUseAsIdentifier(SgDeclarationStatement *declaration)
Generate a useful name to support construction of identifiers from declarations.
ROSE_DLL_API SgScopeStatement * getEnclosingScope(SgNode *n, const bool includingSelf=false)
Get the enclosing scope from a node n.
ROSE_DLL_API bool mergeDeclarationAndAssignment(SgVariableDeclaration *decl, SgExprStatement *assign_stmt, bool removeAssignStmt=true)
Merge a variable assignment statement into a matching variable declaration statement. Callers should make sure the merge is semantically correct (by not introducing compilation errors). This function simply does the merge transformation, without eligibility check.
This class represents the concept of a declaration list.
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 SgVariableSymbol * getFirstVarSym(SgVariableDeclaration *decl)
Get the variable symbol for the first initialized name of a declaration stmt.
ROSE_DLL_API void insertStatementBefore(SgStatement *targetStmt, SgStatement *newStmt, bool autoMovePreprocessingInfo=true)
Insert a statement before a target statement.
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 isUpcSharedModifierType(SgModifierType *mod_type)
Check if a modifier type is a UPC shared type.
ROSE_DLL_API std::string mangleType(SgType *type)
Generate a mangled string for a given type based on Itanium C++ ABI.
ROSE_DLL_API SgExprStatement * splitVariableDeclaration(SgVariableDeclaration *decl)
Split a variable declaration with an rhs assignment into two statements: a declaration and an assignm...
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 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 bool is_Fortran_language()
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 void insertStatementListBefore(SgStatement *targetStmt, const std::vector< SgStatement * > &newStmts)
Insert a list of statements before a target statement.
ROSE_DLL_API bool hasTrivialDestructor(SgType *t)
Does a type have a trivial (built-in) destructor?
ROSE_DLL_API void setOneSourcePositionNull(SgNode *node)
Set current node's source position as NULL.
bool isPostfixOperator(SgExpression *exp)
Is an overloaded operator a postfix operator. (e.g. ).
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.
std::string getMangledNameFromCache(SgNode *astNode)
Save AST into a pdf file. Start from a node to find its enclosing file node. The entire file's AST wi...
ROSE_DLL_API SgFunctionDefinition * getEnclosingFunctionDefinition(SgNode *astNode, const bool includingSelf=false)
Find a node by type using upward traversal.
ROSE_DLL_API SgBasicBlock * ensureBasicBlockAsBodyOfOmpBodyStmt(SgOmpBodyStatement *ompbodyStmt)
Check if the body of a SgOmpBodyStatement is a SgBasicBlock, create one if not.
This class represents the concept of a C or C++ statement which contains a expression.
ROSE_DLL_API SgOmpClauseBodyStatement * findEnclosingOmpClauseBodyStatement(SgStatement *s)
Find enclosing OpenMP clause body statement from s. If s is already one, return it directly...
ROSE_DLL_API AbstractHandle::abstract_handle * buildAbstractHandle(SgNode *)
Build an abstract handle from an AST node, reuse previously built handle when possible.
std::string generateUniqueName(const SgNode *node, bool ignoreDifferenceBetweenDefiningAndNondefiningDeclarations)
Generate unique name from C and C++ constructs. The name may contain space.
ROSE_DLL_API std::string mangleModifierType(SgModifierType *type)
Generated mangled modifier types, include const, volatile,according to Itanium C++ ABI...
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).
This class represents a source file for a project (which may contian many source files and or directo...
ROSE_DLL_API void removeLabeledGotos(SgNode *top)
Remove labeled goto statements.
This class represents the variable declaration or variable initialization withn a for loop...
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...
bool templateDefinitionIsInClass(SgTemplateInstantiationMemberFunctionDecl *memberFunctionDeclaration)
Return true if template definition is in the class, false if outside of class.
ROSE_DLL_API SgMemberFunctionDeclaration * getDefaultConstructor(SgClassDeclaration *classDeclaration)
Get the default constructor from the class declaration.
ROSE_DLL_API bool normalizeForLoopTest(SgForStatement *loop)
Normalize a for loop's test expression ix is normalized to i>= (x...
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 initializeIfStmt(SgIfStmt *ifstmt, SgStatement *conditional, SgStatement *true_body, SgStatement *false_body)
Support function used for variable declarations in conditionals.
Class for traversing the AST.
bool isTemplateInstantiationFromTemplateDeclarationSatisfyingFilter(SgFunctionDeclaration *function, T *filter)
This function detects template instantiations that are relevant when filters are used.
void guardNode(SgLocatedNode *target, std::string guard)
Add preproccessor guard around a given node.
This class represents the rhs of a variable declaration which includes an optional assignment (e...
ROSE_DLL_API SgBasicBlock * ensureBasicBlockAsBodyOfSwitch(SgSwitchStatement *ws)
Check if the body of a 'switch' statement is a SgBasicBlock, create one if not.
ROSE_DLL_API bool is_Java_language()
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 void setPragma(SgPragmaDeclaration *decl, SgPragma *pragma)
Set a pragma of a pragma declaration. handle memory release for preexisting pragma, and set parent pointer.
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 base class for all types.
SgType * removeConst(SgType *t)
Remove const (if present) from a type. stripType() cannot do this because it removes all modifiers...
ROSE_DLL_API SgNode * deepCopyNode(const SgNode *subtree)
Deep copy an arbitrary subtree.
This class represents the concept of a do-while 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...
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 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 concept of a class name within the compiler.
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 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 SgBasicBlock * ensureBasicBlockAsTrueBodyOfIf(SgIfStmt *ifs)
Check if the true body of a 'if' statement is a SgBasicBlock, create one if not.
SgMemberFunctionDeclaration * getDefaultDestructor(SgClassDeclaration *classDeclaration)
Get the default destructor from the class declaration.
ROSE_DLL_API bool isUpcArrayWithThreads(SgArrayType *t)
Is a UPC array with dimension of X*THREADS.
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 appendExpressionList(SgExprListExp *, const std::vector< SgExpression * > &)
Append an expression list to a SgExprListExp, set the parent pointers also.
ROSE_DLL_API std::string mangleScalarType(SgType *type)
Generate mangled scalar type names according to Itanium C++ ABI, the input type should pass isScalarT...
void set_parent(SgNode *parent)
All nodes in the AST contain a reference to a parent node.
void setSourcePositionPointersToNull(SgNode *node)
Set the source code positon for the current (input) node.
ROSE_DLL_API bool isEquivalentFunctionType(const SgFunctionType *lhs, const SgFunctionType *rhs)
Test if two types are equivalent SgFunctionType nodes.
std::vector< SgVariableSymbol * > getSymbolsUsedInExpression(SgExpression *expr)
Find referenced symbols within an expression.
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...
ROSE_DLL_API void setLhsOperand(SgExpression *target, SgExpression *lhs)
set left hand operand for binary expressions, transparently downcasting target expressions when neces...
This class represents the notion of a declared variable.
ROSE_DLL_API void setSourcePositionAtRootAndAllChildren(SgNode *root)
Set the source code positon for the subtree (including the root).
ROSE_DLL_API std::string generateProjectName(const SgProject *project, bool supressSuffix=false)
Added mechanism to generate project name from list of file names.
bool isBodyStatement(SgStatement *s)
Check if a statement is a (true or false) body of a container-like parent, such as For...
ROSE_DLL_API SgVariableSymbol * prependArg(SgFunctionParameterList *, SgInitializedName *)
Prepend an argument to SgFunctionParameterList.
NodeType * deepCopy(const NodeType *subtree)
A template function for deep copying a subtree. It is also used to create deepcopy functions with spe...
This class represents the concept of a member function declaration statement.
This class represents the concept of a C and C++ case option (used within a switch statement)...
SgBasicBlock * ensureBasicBlockAsBodyOfDefaultOption(SgDefaultOptionStmt *cs)
Check if the body of a 'default option' statement is a SgBasicBlock, create one if not...
This class represents the concept of a function declaration statement.
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...
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...
ROSE_DLL_API bool isOmpStatement(SgNode *)
Check if a node is SgOmp*Statement.
bool isStructDeclaration(SgNode *node)
Check if a SgNode is a declaration for a structure.
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::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...
This class represents the concept of a scope in C++ (e.g. global scope, fuction scope, etc.).
SgType * getBoolType(SgNode *n)
Get the right bool type according to C or C++ language input.
ROSE_DLL_API SgSourceFile * getEnclosingSourceFile(SgNode *n, const bool includingSelf=false)
Find enclosing source file node.
ROSE_DLL_API bool is_Python_language()
bool ROSE_DLL_API isStatic(SgDeclarationStatement *stmt)
Check if a declaration has a "static' modifier.
unsigned long long getIntegerConstantValue(SgValueExp *expr)
Get the constant value from a constant integer expression; abort on everything else.
This class represents the concept of a C and C++ expression list.
void clearScopeNumbers(SgFunctionDefinition *functionDefinition)
Clears the cache of scope,integer pairs for the input function.
ROSE_DLL_API void setStatic(SgDeclarationStatement *stmt)
Set a declaration as static.
ROSE_DLL_API void outputLocalSymbolTables(SgNode *node)
Output the local symbol tables.
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 ...
std::string get_name(const SgNode *node)
Generate a useful name to describe the SgNode.
ROSE_DLL_API bool is_binary_executable()
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...
PreprocessingInfo * insertHeader(SgSourceFile *source_file, const std::string &header_file_name, bool isSystemHeader, bool asLastHeader)
Insert #include "filename" or #include (system header) onto the global scope of a source f...
std::vector< SgBreakStmt * > findBreakStmts(SgStatement *code, const std::string &fortranLabel="")
Find break statements inside a particular statement, stopping at nested loops or switches.
ROSE_DLL_API void setSourcePositionForTransformation(SgNode *root)
Recursively set source position info(Sg_File_Info) as transformation generated.
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.
ROSE_DLL_API SgStatement * getLoopBody(SgScopeStatement *loop)
Routines to get and set the body of a loop.
std::vector< SgFile * > generateFileList()
Returns STL vector of SgFile IR node pointers.
std::string generateUniqueNameForUseAsIdentifier_support(SgDeclarationStatement *declaration)
Global map of name collisions to support generateUniqueNameForUseAsIdentifier() function.
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 int set_name(SgInitializedName *initializedNameNode, SgName new_name)
set_name of symbol in symbol table.
void changeAllBodiesToBlocks(SgNode *top, bool createEmptyBody=true)
Fix up ifs, loops, while, switch, Catch, OmpBodyStatement, etc. to have blocks as body components...
ROSE_DLL_API bool isPointerType(SgType *t)
Is this type a pointer type? (Handles typedefs correctly)
bool isOverloaded(SgFunctionDeclaration *functionDeclaration)
Return true if function is overloaded.
ROSE_DLL_API SgNode * getSgNodeFromAbstractHandleString(const std::string &input_string)
Obtain a matching SgNode from an abstract handle string.
ROSE_DLL_API void fixStatement(SgStatement *stmt, SgScopeStatement *scope)
A wrapper containing fixes (fixVariableDeclaration(),fixStructDeclaration(), fixLabelStatement(), etc) for all kinds statements. Should be used before attaching the statement into AST.
ROSE_DLL_API void deleteExpressionTreeWithOriginalExpressionSubtrees(SgNode *root)
Special purpose function for deleting AST expression tress containing valid original expression trees...
ROSE_DLL_API bool isCopyConstructible(SgType *type)
Is a type copy constructible? This may not quite work properly.
This class represents the base class of a numbr of IR nodes that don't otherwise fit into the existin...
Definition: Cxx_Grammar.h:9279
bool isPrefixOperator(SgExpression *exp)
Is an overloaded operator a prefix operator (e.g. address operator X * operator&(), dereference operator X & operator*(), unary plus operator X & operator+(), etc.
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 bool isStructType(SgType *t)
Check if a type is a struct type (a special SgClassType in ROSE)
void resetScopeNumbers(SgFunctionDefinition *functionDeclaration)
Assigns unique numbers to each SgScopeStatement of a function.
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...
SgExpression * forallMaskExpression(SgForAllStatement *stmt)
Get the mask expression from the header of a SgForAllStatement.
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 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, with the step statement after it; then change all continue statements in the old loop body into jumps to the label.
ROSE_DLL_API bool isConstantTrue(SgExpression *e)
Save AST into a pdf file. Start from a node to find its enclosing file node. The entire file's AST wi...
SgDeclarationStatement * getNonInstantiatonDeclarationForClass(SgTemplateInstantiationMemberFunctionDecl *memberFunctionInstantiation)
Save AST into a pdf file. Start from a node to find its enclosing file node. The entire file's AST wi...
ROSE_DLL_API int getDimensionCount(SgType *t)
Get the number of dimensions of an array type.
void visit(SgNode *node)
this method is called at every traversed node.
RelativePositionType
MK: Enum type to store if the directive goes before or after the corresponding line of source code...
void clearMangledNameCache(SgGlobal *globalScope)
Support for faster mangled name generation (caching avoids recomputation).
void whereAmI(SgNode *node)
Diagnostic function for tracing back through the parent list to understand at runtime where in the AS...
ROSE_DLL_API bool isStrictIntegerType(SgType *t)
Check if a type is an integral type, only allowing signed/unsigned short, int, long, long long. /! /! There is another similar function named SgType::isIntegerType(), which allows additional types char, wchar, and bool to be treated as integer types.
ROSE_DLL_API void removeUnusedLabels(SgNode *top)
Remove labels which are not targets of any goto statements.
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 SgInitializer * getInitializerOfExpression(SgExpression *n)
Get the initializer containing an expression if it is within an initializer.
ROSE_DLL_API void replaceExpression(SgExpression *oldExp, SgExpression *newExp, bool keepOldExp=false)
Replace an expression with another, used for variable reference substitution and others. the old expression can be deleted (default case) or kept.
ROSE_DLL_API bool is_OpenMP_language()
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...
This class represents the notion of an expression. Expressions are derived from SgLocatedNodes, since similar to statement, expressions have a concrete location within the user's source code.
ROSE_DLL_API bool is_UPC_language()
ROSE_DLL_API SgBasicBlock * ensureBasicBlockAsBodyOfUpcForAll(SgUpcForAllStatement *fs)
Check if the body of a 'upc_forall' statement is a SgBasicBlock, create one if not.
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...
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.
std::vector< SgContinueStmt * > findContinueStmts(SgStatement *code, const std::string &fortranLabel="")
Find all continue statements inside a particular statement, stopping at nested loops.
void setBaseTypeDefiningDeclaration(SgVariableDeclaration *var_decl, SgDeclarationStatement *base_decl)
a better version for SgVariableDeclaration::set_baseTypeDefininingDeclaration(), handling all side ef...
ROSE_DLL_API void setFortranNumericLabel(SgStatement *stmt, int label_value)
Set a numerical label for a Fortran statement. The statement should have a enclosing function definit...
ROSE_DLL_API bool templateArgumentListEquivalence(const SgTemplateArgumentPtrList &list1, const SgTemplateArgumentPtrList &list2)
Verify that 2 SgTemplateArgumentPtrList are equivalent.
const SgInitializedNamePtrList & get_args() const
Access function for p_args.
ROSE_DLL_API SgGlobal * getGlobalScope(const SgNode *astNode)
Traverse back through a node's parents to find the enclosing global scope.
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...
This class represents the concept of a name within the compiler.
T * findDeclarationStatement(SgNode *root, std::string name, SgScopeStatement *scope, bool isDefining)
Topdown traverse a subtree from root to find the first declaration given its name, scope (optional, can be NULL), and defining or nondefining flag.
ROSE_DLL_API SgInitializedName * convertRefToInitializedName(SgNode *current, bool coarseGrain=true)
Variable references can be introduced by SgVarRef, SgPntrArrRefExp, SgInitializedName, SgMemberFunctionRef etc. For Dot and Arrow Expressions, their lhs is used to obtain SgInitializedName (coarse grain) by default. Otherwise, fine-grain rhs is used.
void dumpPreprocInfo(SgLocatedNode *locatedNode)
Dumps a located node's preprocessing information.
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)
ROSE_DLL_API void replaceSubexpressionWithStatement(SgExpression *from, SageInterface::StatementGenerator *to)
Similar to replaceExpressionWithStatement, but with more restrictions.
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...
SgCommaOpExp * insertBeforeUsingCommaOp(SgExpression *new_exp, SgExpression *anchor_exp)
Insert an expression (new_exp )before another expression (anchor_exp) has possible side effects...
Supporting class from copy mechanism within ROSE.
Definition: Cxx_Grammar.h:8070
ROSE_DLL_API void setSourcePosition(SgNode *node)
Set the source code positon for the current (input) node.
ROSE_DLL_API bool isPureVirtualClass(SgType *type, const ClassHierarchyWrapper &classHierarchy)
Check if a class type is a pure virtual class.
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 ...
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...
ROSE_DLL_API SgGlobal * getFirstGlobalScope(SgProject *project)
return the first global scope under current project
ROSE_DLL_API void replaceExpressionWithStatement(SgExpression *from, SageInterface::StatementGenerator *to)
Replace a given expression with a list of statements produced by a generator.
ROSE_DLL_API void fixStructDeclaration(SgClassDeclaration *structDecl, SgScopeStatement *scope)
Fix symbols, parent and scope pointers. Used internally within appendStatment(), insertStatement() et...
ROSE_DLL_API SgType * getFirstVarType(SgVariableDeclaration *decl)
Get the data type of the first initialized name of a declaration statement.
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. Exclude private pointers to shared types. Optionally return the modifier type with the UPC shared property.
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, with the step statement after it; then change all continue statements in the old loop body into jumps to the label.
ROSE_DLL_API int collectVariableReferencesInArrayTypes(SgLocatedNode *root, Rose_STL_Container< SgNode * > &currentVarRefList)
Collect variable references in array types. The default NodeQuery::querySubTree() will miss variables...
This class represents the concept of a class definition in C++.
This class represents strings within the IR nodes.
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...
void resetMangledNameCache(SgGlobal *globalScope)
Save AST into a pdf file. Start from a node to find its enclosing file node. The entire file's AST wi...
ROSE_DLL_API SgBasicBlock * ensureBasicBlockAsBodyOfWhile(SgWhileStmt *ws)
Check if the body of a 'while' statement is a SgBasicBlock, create one if not.
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...
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 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 bool isMain(const SgNode *node)
Check if a SgNode is a main() function declaration.
ROSE_DLL_API void setExtern(SgDeclarationStatement *stmt)
Set a declaration as extern.
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...
std::vector< SgStatement * > getSwitchCases(SgSwitchStatement *sw)
Query a subtree to get all nodes of a given type, with an appropriate downcast.
void setSourcePositionAsTransformation(SgNode *node)
DQ (5/1/2012): New function with improved name.
bool isPrototypeInScope(SgScopeStatement *scope, SgFunctionDeclaration *functionDeclaration, SgDeclarationStatement *startingAtDeclaration)
Assigns unique numbers to each SgScopeStatement of a function.
Functions that are useful when operating on the AST.
Definition: sageBuilder.h:25
ROSE_DLL_API bool doLoopNormalization(SgFortranDo *loop)
Normalize a Fortran Do loop. Make the default increment expression (1) explicit.
ROSE_DLL_API bool isConstantFalse(SgExpression *e)
Save AST into a pdf file. Start from a node to find its enclosing file node. The entire file's AST wi...
ROSE_DLL_API bool isExtern(SgDeclarationStatement *stmt)
Check if a declaration has an "extern" modifier.
ROSE_DLL_API SgFunctionDeclaration * findMain(SgNode *currentNode)
top-down traversal from current node to find the main() function declaration
ROSE_DLL_API SgInitializedName * getFirstInitializedName(SgVariableDeclaration *decl)
Get the first initialized name of a declaration statement.
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 ...
ROSE_DLL_API bool is_UPC_dynamic_threads()
Check if dynamic threads compilation is used for UPC programs.
ROSE_DLL_API void cleanupNontransformedBasicBlockNode()
Remove unused basic block IR nodes added as part of normalization.
ROSE_DLL_API void setOperand(SgExpression *target, SgExpression *operand)
Set operands for expressions with single operand, such as unary expressions. handle file info...
ROSE_DLL_API bool isVolatileType(SgType *t)
Is this a volatile type?
ROSE_DLL_API SgAssignInitializer * splitExpression(SgExpression *from, std::string newName="")
Replace an expression with a temporary variable and an assignment statement.
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 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 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...
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.
This class represents the concept of a namespace name within the compiler.
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).
SgBasicBlock * ensureBasicBlockAsBodyOfCaseOption(SgCaseOptionStmt *cs)
Check if the body of a 'case option' statement is a SgBasicBlock, create one if not.
This class represents the base class for all IR nodes within Sage III.
Definition: Cxx_Grammar.h:8322
This class represents the concept of a catch within a try-catch construct used in C++ exception handl...
uint64_t getAsmConstant(SgAsmValueExpression *e)
Get the unsigned value of a disassembled constant.
This class represents the notion of an value (expression value).
This class represents the concept of a variable name within the compiler (a shared container for the ...
This class represents the concept of an instantiation of function template.
bool isPrefixOperatorName(const SgName &functionName)
Check for proper names of possible prefix operators (used in isPrefixOperator()). ...
bool isUnionDeclaration(SgNode *node)
Check if a SgNode is a declaration for a union.
ROSE_DLL_API std::set< SgStatement * > collectTransformedStatements(SgNode *node)
This collects the statements that are marked as transformed (useful in debugging).
NodeType * getEnclosingNode(const SgNode *astNode, const bool includingSelf=false)
Find a node by type using upward traversal.
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 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, with the step statement after it; then change all continue statements in the old loop body into jumps to the label.
SgTemplateMemberFunctionDeclaration * get_templateDeclaration() const
Returns pointer to SgTemplateDeclaration from which instantiation is generated.
std::vector< SgDeclarationStatement * > getDependentDeclarations(SgStatement *stmt)
Get a statement's dependent declarations which declares the types used in the statement. The returned vector of declaration statements are sorted according to their appearance order in the original AST. Any reference to a class or template class from a namespace will treated as a reference to the enclosing namespace.
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 SgClassDefinition * getEnclosingClassDefinition(SgNode *astnode, const bool includingSelf=false)
Get the closest class definition enclosing the specified AST node,.
std::map< std::string, SgNode * > local_name_to_node_map
Global map of name collisions to support generateUniqueNameForUseAsIdentifier() function.
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...
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 unnormalizeForLoopInitDeclaration(SgForStatement *loop)
Undo the normalization of for loop's C99 init declaration. Previous record of normalization is used t...
ROSE_DLL_API bool is_OpenCL_language()
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 isLastStatement(SgStatement *stmt)
Check if a statement is the last statement within its closed scope.
ROSE_DLL_API SgType * getAssociatedTypeFromFunctionTypeList(SgExpression *actual_argument_expression)
Get the type of the associated argument expression from the function type.
ROSE_DLL_API SgBasicBlock * ensureBasicBlockAsBodyOfFor(SgForStatement *fs)
Check if the body of a 'for' statement is a SgBasicBlock, create one if not.
std::vector< SgExpression * > get_C_array_dimensions(const SgArrayType &arrtype)
returns the array dimensions in an array as defined for arrtype
This class represents the concept of a block (not a basic block from control flow analysis)...
This class represents the concept of a C++ namespace declaration.
ROSE_DLL_API SgFunctionDefinition * getEnclosingProcedure(SgNode *n, const bool includingSelf=false)
Find the function definition.
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 notion of a statement.
For preprocessing information including source comments, #include , #if, #define, etc...
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...
ROSE_DLL_API bool is_C_language()
This class represents the concept of a namespace definition.
This class represents the concept of a for loop.
ROSE_DLL_API SgStatement * getLastStatement(SgScopeStatement *scope)
get the last statement within a scope, return NULL if it does not exit
void clearUnusedVariableSymbols(SgNode *root=NULL)
Clear those variable symbols with unknown type (together with initialized names) which are also not r...
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 void resetInternalMapsForTargetStatement(SgStatement *sourceStatement)
Function to delete AST subtree's nodes only, users must take care of any dangling pointers...
SgDeclarationStatement * get_definingDeclaration() const
This is an access function for the SgDeclarationStatement::p_definingDeclaration data member (see tha...
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 SgInitializedName * getLoopIndexVariable(SgNode *loop)
Return the loop index variable for a for loop.
ROSE_DLL_API bool is_X10_language()
This class represents a type for all functions.
void annotateExpressionsWithUniqueNames(SgProject *project)
Generate unique names for expressions and attach the names as persistent attributes ("UniqueNameAttri...
SgInitializedName & getFirstVariable(SgVariableDeclaration &vardecl)
convenience function that returns the first initialized name in a list of variable declarations...
ROSE_DLL_API bool isCallToParticularFunction(SgFunctionDeclaration *decl, SgExpression *e)
Save AST into a pdf file. Start from a node to find its enclosing file node. The entire file's AST wi...
This class represents the concept of a namespace definition.
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...
ROSE_DLL_API SgStatement * copyStatement(SgStatement *s)
Deep copy a statement.
void addMessageStatement(SgStatement *stmt, std::string message)
Function to add "C" style comment to statement.
ROSE_DLL_API SgBasicBlock * ensureBasicBlockAsBodyOfCatch(SgCatchOptionStmt *cos)
Check if the body of a 'catch' statement is a SgBasicBlock, create one if not.
ROSE_DLL_API bool isScalarType(SgType *t)
Is this a scalar type?
This class represents the concept of a C Assembler statement (untested).
ROSE_DLL_API void appendExpression(SgExprListExp *, SgExpression *)
Append an expression to a SgExprListExp, set the parent pointer also.
ROSE_DLL_API void updateDefiningNondefiningLinks(SgFunctionDeclaration *func, SgScopeStatement *scope)
Update defining and nondefining links due to a newly introduced function declaration. Should be used after inserting the function into a scope.
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, shared scalar/array)? An optional parameter, mod_type_out, stores the first SgModifierType with UPC access information.
bool isIndexOperator(SgExpression *exp)
Is an overloaded operator an index operator (also referred to as call or subscript operators)...
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 bool isNonconstReference(SgType *t)
Is this type a non-constant reference type? (Handles typedefs correctly)
This class represents the concept of a C or C++ default case within a switch statement.
ROSE_DLL_API bool templateArgumentEquivalence(SgTemplateArgument *arg1, SgTemplateArgument *arg2)
Verify that 2 SgTemplateArgument are equivalent (same type, same expression, or same template declara...
This class represents the concept of an "if" construct.
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...
to specify a construct using a specifier Can be used alone or with parent handles when relative speci...
ROSE_DLL_API void fixVariableDeclaration(SgVariableDeclaration *varDecl, SgScopeStatement *scope)
Patch up symbol, scope, and parent information when a SgVariableDeclaration's scope is known...
virtual std::string class_name() const
returns a string representing the class name
ROSE_DLL_API void deleteAST(SgNode *node)
Function to delete AST subtree's nodes only, users must take care of any dangling pointers...
std::vector< SgGotoStatement * > findGotoStmts(SgStatement *scope, SgLabelStatement *l)
Query a subtree to get all nodes of a given type, with an appropriate downcast.
virtual std::vector< SgNode * > get_traversalSuccessorContainer()
container of pointers to AST successor nodes used in the traversal overridden in every class by gener...
ROSE_DLL_API SgScopeStatement * getScope(const SgNode *astNode)
Get the closest scope from astNode. Return astNode if it is already a scope.
void setParameterList(actualFunction *func, SgFunctionParameterList *paralist)
Set parameter list for a function declaration, considering existing parameter list etc...
This class represents the concept of a template declaration.
ROSE_DLL_API void fixClassDeclaration(SgClassDeclaration *classDecl, SgScopeStatement *scope)
Fix symbols, parent and scope pointers. Used internally within appendStatment(), insertStatement() et...
ROSE_DLL_API int fixVariableReferences(SgNode *root)
Connect variable reference to the right variable symbols when feasible, return the number of referenc...
ROSE_DLL_API bool forLoopNormalization(SgForStatement *loop, bool foldConstant=true)
Normalize a for loop, return true if successful.
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 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...
This class represents the notion of an expression or statement which has a position within the source...
ROSE_DLL_API bool isReferenceType(SgType *t)
Is this type a const or non-const reference type? (Handles typedefs correctly)
This class represents template argument within the use of a template to build an instantiation.
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...
This class represents the variable refernece in expressions.
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 ...
This class represents the concept of a do-while statement.
ROSE_DLL_API std::vector< SgNode * > astIntersection(SgNode *original, SgNode *copy, SgCopyHelp *help=NULL)
Compute the intersection set for two ASTs.
ROSE_DLL_API bool isUpcPrivateToSharedType(SgType *t)
Is a UPC private-to-shared pointer? SgPointerType comes first compared to SgModifierType with UPC inf...
void initializeSwitchStatement(SgSwitchStatement *switchStatement, SgStatement *item_selector, SgStatement *body)
Support function used for variable declarations in conditionals.
std::map< std::string, int > local_name_collision_map
Global map of name collisions to support generateUniqueNameForUseAsIdentifier() function.
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...
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...
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 isDefaultConstructible(SgType *type)
Is a type default constructible? This may not quite work properly.
ROSE_DLL_API void wrapAllTemplateInstantiationsInAssociatedNamespaces(SgProject *root)
Function to delete AST subtree's nodes only, users must take care of any dangling pointers...
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, with the step statement after it; then change all continue statements in the old loop body into jumps to the label.
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 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...
Base class for values.
SgTemplateInstantiationMemberFunctionDecl * buildForwardFunctionDeclaration(SgTemplateInstantiationMemberFunctionDecl *memberFunctionInstantiation)
Generate a non-defining (forward) declaration from a defining function declaration.
ROSE_DLL_API bool mergeDeclarationWithAssignment(SgVariableDeclaration *decl, SgExprStatement *assign_stmt)
Merge a declaration statement into a matching followed variable assignment. Callers should make sure ...
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 isAssignable(SgType *type)
Is a type assignable? This may not quite work properly.
ROSE_DLL_API void setLoopLowerBound(SgNode *loop, SgExpression *lb)
Set the lower bound of a loop header for (i=lb; ...)
ROSE_DLL_API SgProject * getProject()
Get the current SgProject IR Node.
ROSE_DLL_API bool is_PHP_language()
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, with the step statement after it; then change all continue statements in the old loop body into jumps to the label.
ROSE_DLL_API void splitExpressionIntoBasicBlock(SgExpression *expr)
Split long expressions into blocks of statements.
void initializeWhileStatement(SgWhileStmt *whileStatement, SgStatement *condition, SgStatement *body, SgStatement *else_body)
Support function used for variable declarations in conditionals.
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...
ROSE_DLL_API void removeConsecutiveLabels(SgNode *top)
Remove consecutive labels.
ROSE_DLL_API void setOneSourcePositionForTransformation(SgNode *root)
Set current node's source position as transformation generated.
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 setRhsOperand(SgExpression *target, SgExpression *rhs)
set left hand operand for binary expression
SgNode * get_parent() const
Access function for parent node.
ROSE_DLL_API void myRemoveStatement(SgStatement *stmt)
A special purpose statement removal function, originally from inlinerSupport.h, Need Jeremiah's atten...
bool functionCallExpressionPreceedsDeclarationWhichAssociatesScope(SgFunctionCallExp *functionCall)
Save AST into a pdf file. Start from a node to find its enclosing file node. The entire file's AST wi...
ROSE_DLL_API int suggestNextNumericLabel(SgFunctionDefinition *func_def)
Suggest next usable (non-conflicting) numeric label value for a Fortran function definition scope...
ROSE_DLL_API int gensym_counter
An internal counter for generating unique SgName.
ROSE_DLL_API bool isEqualToIntConst(SgExpression *e, int value)
Check if a SgIntVal node has a given value.
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 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 void changeContinuesToGotos(SgStatement *stmt, SgLabelStatement *label)
Change continue statements in a given block of code to gotos to a label.
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 bool is_Cxx_language()
void rebuildSymbolTable(SgScopeStatement *scope)
Regenerate the symbol table.
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 bool isConstType(SgType *t)
Is this a const type?
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 bool isRestrictType(SgType *t)
Is this a restrict type?
ROSE_DLL_API bool is_C99_language()
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.
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 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 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 ...
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...
virtual std::string class_name() const ROSE_OVERRIDE
returns a string representing the class name
ROSE_DLL_API SgVariableSymbol * appendArg(SgFunctionParameterList *, SgInitializedName *)
Append an argument to SgFunctionParameterList, transparently set parent,scope, and symbols for argume...
ROSE_DLL_API bool isTemplateInstantiationNode(SgNode *node)
Function to delete AST subtree's nodes only, users must take care of any dangling pointers...
ROSE_DLL_API bool is_mixed_Fortran_and_C_language()
SgNamespaceDefinitionStatement * enclosingNamespaceScope(SgDeclarationStatement *declaration)
Find the enclosing namespace of a declaration.
ROSE_DLL_API bool is_CAF_language()
ROSE_DLL_API void removeJumpsToNextStatement(SgNode *)
Remove jumps whose label is immediately after the jump. Used to clean up inlined code fragments...
void collectVarRefs(SgLocatedNode *root, std::vector< SgVarRefExp * > &result)
Collect all variable references in a subtree.
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 void deepDelete(SgNode *root)
Deep delete a sub AST tree. It uses postorder traversal to delete each child node. Users must take care of any dangling pointers, symbols or types that result. This is identical to deleteAST()
std::string declarationPositionString(const SgDeclarationStatement *declaration)
Generate a unique string from the source file position information.
This class represents the concept of a C or C++ variable declaration.
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, starting from top of ScopeStack if currentscope is not given or NULL
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...
std::map< SgNode *, std::string > local_node_to_name_map
Global map of name collisions to support generateUniqueNameForUseAsIdentifier() function.
Represents an interpretation of a binary container.
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 ...
This class represents the concept of a C or C++ label statement.
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...
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...
SgDeclarationStatement * get_firstNondefiningDeclaration() const
This is an access function for the SgDeclarationStatement::p_firstNondefiningDeclaration data member ...
ROSE_DLL_API void dumpInfo(SgNode *node, std::string desc="")
Dump information about a SgNode for debugging.
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 void fixNamespaceDeclaration(SgNamespaceDeclarationStatement *structDecl, SgScopeStatement *scope)
Fix symbols, parent and scope pointers. Used internally within appendStatment(), insertStatement() et...
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. Move around preprocessing info automatically.
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, a scope, or a single line statement. For accesses to members of aggregate data, we return the coarse grain aggregate mem obj by default.
This class represents the concept of a C++ function call (which is an expression).
void reset_name_collision_map()
Reset map variables used to support generateUniqueNameForUseAsIdentifier() function.
Base class for binary files.
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 addStepToLoopBody(SgScopeStatement *loopStmt, SgStatement *step)
Add a step statement to the end of a loop body Add a new label to the end of the loop, with the step statement after it; then change all continue statements in the old loop body into jumps to the label.
ROSE_DLL_API bool is_Cuda_language()
ROSE_DLL_API SgNode * replaceWithPattern(SgNode *anchor, SgNode *new_pattern)
Replace an anchor node with a specified pattern subtree with optional SgVariantExpression. All SgVariantExpression in the pattern will be replaced with copies of the anchor node.
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...
std::string addMangledNameToCache(SgNode *astNode, const std::string &mangledName)
Save AST into a pdf file. Start from a node to find its enclosing file node. The entire file's AST wi...
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) ...
This class represents the concept of a declaration statement.
virtual SgName get_name() const =0
Access function for getting name from declarations or types internally.
This class represents the concept of a switch.
ROSE_DLL_API SgExpression * copyExpression(SgExpression *e)
Deep copy an expression.
int64_t getAsmSignedConstant(SgAsmValueExpression *e)
Get the signed value of a disassembled constant.
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...
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...
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 moveToSubdirectory(std::string directoryName, SgFile *file)
Move file to be generated in a subdirectory (will be generated by the unparser).
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 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 is_mixed_C_and_Cxx_language()
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...